From: Kostya Shishkov Date: Sat, 17 Oct 2020 08:11:20 +0000 (+0200) Subject: format time with hours X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;ds=sidebyside;h=be48734ef6a88e831d04ddec9bd56e52c983f489;hp=98431ed56fad70a277a396aea69a67919b52a3ab;p=nihav-player.git format time with hours --- diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index 990507d..176a6d1 100644 --- a/sndplay/src/main.rs +++ b/sndplay/src/main.rs @@ -193,10 +193,15 @@ fn format_time(ms: u64) -> String { let s = ms / 1000; let ds = (ms % 1000) / 100; let (min, s) = (s / 60, s % 60); - if min == 0 { - format!("{}.{}", s, ds) + let (h, min) = (min / 60, min % 60); + if h == 0 { + if min == 0 { + format!("{}.{}", s, ds) + } else { + format!("{}:{:02}.{}", min, s, ds) + } } else { - format!("{}:{:02}.{}", min, s, ds) + format!("{}:{:02}:{:02}.{}", h, min, s, ds) } }