From e24e199e9effe0269f4949e1beb6815404e44801 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Thu, 19 May 2022 04:59:34 +0200 Subject: [PATCH] Create a Seasons enum --- src/main.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.rs b/src/main.rs index fb68411..aad43df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ extern crate smithay_client_toolkit as sctk; +use std::fmt; use std::time::SystemTime; use chrono::prelude::Local; @@ -23,6 +24,24 @@ const HOUR_NAMES: [&str; 24] = [ "Mushroom", "Thunder", "Frost", "Lantern", ]; +enum Season { + Spring, + Summer, + Autumn, + Winter, +} + +impl fmt::Display for Season { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", match self { + Season::Spring => "spring", + Season::Summer => "summer", + Season::Autumn => "autumn", + Season::Winter => "winter", + }) + } +} + fn seconds_to_degrees(seconds: i32) -> f32 { seconds as f32 * 360.0 / 86400.0 }