From 9619435c03ff9e7211f3a61d4270bb95f92c0767 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Fri, 2 Aug 2024 11:13:36 +0300 Subject: [PATCH] fix(tasks): time display format replacements --- src/tasks.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tasks.rs b/src/tasks.rs index 1db679f..c609662 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -579,13 +579,18 @@ impl Tasks { } } +/// Formats the given seconds according to the given format. +/// MMM - minutes +/// MM - minutes of the hour +/// HH - hours +/// Returns an empty string if under a minute. fn display_time(format: &str, secs: u64) -> String { Some(secs / 60) .filter(|t| t > &0) .map_or(String::new(), |mins| format + .replace("MMM", &format!("{:3}", mins)) .replace("HH", &format!("{:02}", mins.div(60))) .replace("MM", &format!("{:02}", mins.rem(60))) - .replace("MMM", &format!("{:3}", mins)), ) }