Create a Seasons enum

This commit is contained in:
Gergely Polonkai 2022-05-19 04:59:34 +02:00
parent 08cb444e7d
commit e24e199e9e
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
1 changed files with 19 additions and 0 deletions

View File

@ -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
}