sktchrs/src/clock.rs
2023-10-18 15:28:44 -05:00

21 lines
430 B
Rust

use chrono::prelude::*;
pub struct Clock {
pub command: String,
}
impl Clock {
pub fn new() -> Self {
Clock {
command: String::new(),
}
}
pub fn update(&mut self) {
let t: DateTime<Utc> = Utc::now();
let time = t.format("%H:%M");
let date = t.format("%a %d. %b");
self.command = format!("--set calendar icon=\"{}\" label=\"{}\"", date, time);
}
}