From cbcb44de1820856fe415a29f4b1ac6f2cb83d5f2 Mon Sep 17 00:00:00 2001 From: ochibani <11yzyv86j@relay.firefox.com> Date: Wed, 2 Nov 2022 14:24:27 +0200 Subject: [PATCH] add hours to timer --- src/timer.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/timer.rs b/src/timer.rs index 3e77fd9..bd91ee2 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -11,7 +11,7 @@ pub fn recording_delay(delay_spin: SpinButton, mut delay_time: u64, delay_window // Show delay window if delay time is not zero delay_window.show(); if delay_time > 0 { - delay_window_label.set_text(¤t_time(delay_time)); + delay_window_label.set_text(¤t_delay_time(delay_time)); delay_time -= 1; if delay_window_button.is_active() { delay_window.hide(); @@ -37,7 +37,7 @@ pub fn start_timer(record_time_label: Label) { let mut start_time = 0; let capture_record_label = move || { if record_time_label.is_visible() { - record_time_label.set_text(¤t_time(start_time)); + record_time_label.set_text(¤t_record_time(start_time)); start_time += 1; glib::source::Continue(true) } else { @@ -50,11 +50,16 @@ pub fn start_timer(record_time_label: Label) { pub fn stop_timer(record_time_label: Label) { let stop_time = 0; - record_time_label.set_text(¤t_time(stop_time)); + record_time_label.set_text(¤t_record_time(stop_time)); } -fn current_time(delay_time: u64) -> String { +fn current_delay_time(delay_time: u64) -> String { let delay = secfmt::from(delay_time); format!("{:02}:{:02}", delay.minutes, delay.seconds) } + +fn current_record_time(start_time: u64) -> String { + let start = secfmt::from(start_time); + format!("{:02}:{:02}:{:02}", start.hours, start.minutes, start.seconds) +}