Use full datetime when mocking the clock

Having the date and seconds show is really helpful for debugging
This commit is contained in:
Albert Armea 2025-12-30 09:48:51 -05:00
parent 5cc577a012
commit 8e754d7c77
2 changed files with 8 additions and 2 deletions

View file

@ -185,6 +185,7 @@ fn build_hud_content(state: SharedState) -> gtk4::Box {
let clock_label = gtk4::Label::new(Some("--:--")); let clock_label = gtk4::Label::new(Some("--:--"));
clock_label.add_css_class("clock-label"); clock_label.add_css_class("clock-label");
clock_box.append(&clock_label); clock_box.append(&clock_label);
let mut clock_format_full = false;
// Add mock indicator if mock time is active (debug builds only) // Add mock indicator if mock time is active (debug builds only)
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
@ -193,6 +194,7 @@ fn build_hud_content(state: SharedState) -> gtk4::Box {
let mock_indicator = gtk4::Label::new(Some("(MOCK)")); let mock_indicator = gtk4::Label::new(Some("(MOCK)"));
mock_indicator.add_css_class("mock-time-indicator"); mock_indicator.add_css_class("mock-time-indicator");
clock_box.append(&mock_indicator); clock_box.append(&mock_indicator);
clock_format_full = true;
} }
} }
@ -369,7 +371,11 @@ fn build_hud_content(state: SharedState) -> gtk4::Box {
glib::timeout_add_local(Duration::from_millis(500), move || { glib::timeout_add_local(Duration::from_millis(500), move || {
// Update wall clock display // Update wall clock display
let current_time = shepherd_util::now(); let current_time = shepherd_util::now();
clock_label_clone.set_text(&shepherd_util::format_clock_time(&current_time)); if clock_format_full {
clock_label_clone.set_text(&shepherd_util::format_datetime_full(&current_time));
} else {
clock_label_clone.set_text(&shepherd_util::format_clock_time(&current_time));
}
// Update session state // Update session state
let session_state = state.session_state(); let session_state = state.session_state();

View file

@ -99,7 +99,7 @@ pub fn format_clock_time(dt: &DateTime<Local>) -> String {
/// Format a DateTime for display with full date and time. /// Format a DateTime for display with full date and time.
pub fn format_datetime_full(dt: &DateTime<Local>) -> String { pub fn format_datetime_full(dt: &DateTime<Local>) -> String {
dt.format("%Y-%m-%d %H:%M:%S").to_string() dt.format("%Y-%m-%d %l:%M:%S %p").to_string()
} }
/// Represents a point in monotonic time for countdown enforcement. /// Represents a point in monotonic time for countdown enforcement.