From 1869866eb174e3a796e7ff16ab51535d8201ab95 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Fri, 13 Nov 2026 23:46:11 -0700 Subject: it prints a time now no auto-update though Force-Push: yes Change-Id: I95804235a03540c13a42241712a42ca0704a34ea --- src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index aa0eb0c..0276a45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ use crate::x::*; use std::sync::Arc; +use time::OffsetDateTime; +use time::format_description::{ FormatDescriptionV3, parse_owned }; use xcb::{ Xid }; use xcb::x::{ ClientMessageData, @@ -36,6 +38,7 @@ struct Dock { bounds: Arc>, font: Arc, baseline_position: i16, + time_format: FormatDescriptionV3<'static>, } impl HasWindow for Dock { @@ -122,11 +125,17 @@ impl Dock { + vertical_padding as i16 + configuration.baseline_offset as i16; + let time_format_string = + "[weekday repr:short] [year]-[month]-[day] ".to_owned() + + "[hour repr:24]:[minute]:[second]"; + let time_format = parse_owned::<3>(&time_format_string).unwrap(); + let dock = Dock { window, configuration, bounds: Arc::new(dock_bounds), font, - baseline_position + baseline_position, + time_format, }; dock.set_string_property(&xcb::x::ATOM_WM_NAME, b"sandbar")?; @@ -233,7 +242,8 @@ impl Dock { } self.draw_text("playful cool fic tech nonfic", Alignment::Left)?; - self.draw_text("2026", Alignment::Right)?; + let time = OffsetDateTime::now_local().unwrap(); + self.draw_text(&time.format(&self.time_format).unwrap(), Alignment::Right)?; Ok(()) } -- cgit 1.4.1