[Refactor] Move UTC offset calculation to the clock module
This commit is contained in:
parent
eecd5c2938
commit
8968507d29
@ -94,3 +94,7 @@ pub fn get_hms(config: &Option<Config>, 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()
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user