diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-17 10:11:20 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-17 10:11:20 +0200 |
commit | be48734ef6a88e831d04ddec9bd56e52c983f489 (patch) | |
tree | 3e3a2f60bce6870678a0d2fa54ba060f6710efa9 | |
parent | 98431ed56fad70a277a396aea69a67919b52a3ab (diff) | |
download | nihav-player-be48734ef6a88e831d04ddec9bd56e52c983f489.tar.gz |
format time with hours
-rw-r--r-- | sndplay/src/main.rs | 11 |
1 files changed, 8 insertions, 3 deletions
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) } } |