diff --git a/src/clock.rs b/src/clock.rs index 5a79b59..cab98a4 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -1,7 +1,11 @@ -use chrono::{prelude::Local, Timelike}; +use chrono::{ + prelude::{Local, Utc}, + Timelike, +}; pub enum DayPart { LocalNow, + UtcNow, } pub fn get_moon_phase() -> f32 { @@ -17,6 +21,10 @@ pub fn get_seconds_since_midnight(which: DayPart) -> i32 { let seconds = match which { DayPart::LocalNow => local_timestamp.time().num_seconds_from_midnight(), + DayPart::UtcNow => local_timestamp + .with_timezone(&Utc) + .time() + .num_seconds_from_midnight(), }; seconds as i32 diff --git a/src/svg_clock.rs b/src/svg_clock.rs index 9c7d1fe..e9a575b 100644 --- a/src/svg_clock.rs +++ b/src/svg_clock.rs @@ -342,7 +342,7 @@ pub fn gen_svg( hour_name_path_cache: &[(PathData, PathData); 24], ) -> Document { let local_timestamp = Local::now(); - let utc_hour = local_timestamp.with_timezone(&Utc).time().hour(); + let (utc_hour, _, _) = get_hms(DayPart::UtcNow); let (local_hour, local_minute, local_second) = get_hms(DayPart::LocalNow); let unixtime = suncalc::Timestamp(local_timestamp.timestamp_millis());