format time with hours
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 17 Oct 2020 08:11:20 +0000 (10:11 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 17 Oct 2020 08:11:20 +0000 (10:11 +0200)
sndplay/src/main.rs

index 990507d963cd452e48f1c3e787e19c4725923f73..176a6d189d8e55b3821ca9c747aa17513ad4b81d 100644 (file)
@@ -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)
     }
 }