diff --git a/src/clock.rs b/src/clock.rs index c7e0981..32e9493 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -94,3 +94,7 @@ pub fn get_hms(config: &Option, which: DayPart) -> (u8, u8, u8) { (hours as u8, minutes as u8, seconds as u8) } + +pub fn get_utc_offset() -> i32 { + Local::now().offset().local_minus_utc() +} diff --git a/src/svg_clock.rs b/src/svg_clock.rs index 03f830c..6a110d6 100644 --- a/src/svg_clock.rs +++ b/src/svg_clock.rs @@ -1,6 +1,5 @@ use std::fmt; -use chrono::prelude::Local; use rctree::Node; use svg::{ node::{ @@ -14,7 +13,7 @@ use svg::{ }; use usvg::Tree; -use crate::clock::{get_hms, get_moon_phase, get_seconds_since_midnight, DayPart}; +use crate::clock::{get_hms, get_moon_phase, get_seconds_since_midnight, get_utc_offset, DayPart}; use crate::config::Config; const HOUR_NAMES: [&str; 24] = [ @@ -341,7 +340,7 @@ pub fn gen_svg( let (utc_hour, _, _) = get_hms(config, DayPart::UtcNow); let (local_hour, local_minute, local_second) = get_hms(config, DayPart::LocalNow); - let utc_offset = Local::now().offset().local_minus_utc(); + let utc_offset = get_utc_offset(); let local_time = get_seconds_since_midnight(config, DayPart::LocalNow); let utc_rotation = seconds_to_degrees(utc_offset); let moon_radius = IMAGE_WIDTH as f32 * 0.071428571;