[Refactor] Move current hour name calculation to the clock module
This commit is contained in:
parent
5095d2cc9f
commit
b2e387fbe8
@ -108,3 +108,9 @@ pub fn get_utc_offset() -> i32 {
|
|||||||
pub fn get_utc_hour_name(hour: usize) -> &'static str {
|
pub fn get_utc_hour_name(hour: usize) -> &'static str {
|
||||||
HOUR_NAMES[hour]
|
HOUR_NAMES[hour]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_current_hour_name() -> &'static str {
|
||||||
|
let (utc_hour, _, _) = get_hms(&None, DayPart::UtcNow);
|
||||||
|
|
||||||
|
get_utc_hour_name(utc_hour as usize)
|
||||||
|
}
|
||||||
|
@ -14,7 +14,8 @@ use svg::{
|
|||||||
use usvg::Tree;
|
use usvg::Tree;
|
||||||
|
|
||||||
use crate::clock::{
|
use crate::clock::{
|
||||||
get_hms, get_moon_phase, get_seconds_since_midnight, get_utc_hour_name, get_utc_offset, DayPart,
|
get_current_hour_name, get_hms, get_moon_phase, get_seconds_since_midnight, get_utc_hour_name,
|
||||||
|
get_utc_offset, DayPart,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
@ -595,7 +596,7 @@ pub fn gen_svg(
|
|||||||
"y",
|
"y",
|
||||||
(current_box_height / 5.0) + (current_hour_name_font_size / 2.0),
|
(current_box_height / 5.0) + (current_hour_name_font_size / 2.0),
|
||||||
)
|
)
|
||||||
.add(TextNode::new(get_utc_hour_name(utc_hour as usize)));
|
.add(TextNode::new(get_current_hour_name()));
|
||||||
|
|
||||||
let current_time_text = Text::new()
|
let current_time_text = Text::new()
|
||||||
.set("font-size", current_time_font_size)
|
.set("font-size", current_time_font_size)
|
||||||
|
Loading…
Reference in New Issue
Block a user