Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / scripts / maps / dem_ingest / src / progress.rs

progress.rs16 lines · 464 BRaw
1//! Progress-line helpers for the stderr tile counter: h/m/s durations.
2
3/// Format a duration in seconds as h/m/s (`1h23m45s`, `23m10s`, `45s`).
4pub fn fmt_hms(secs: f64) -> String {
5 let total = secs.max(0.0).round() as u64;
6 let h = total / 3600;
7 let m = (total % 3600) / 60;
8 let s = total % 60;
9 if h > 0 {
10 format!("{h}h{m:02}m{s:02}s")
11 } else if m > 0 {
12 format!("{m}m{s:02}s")
13 } else {
14 format!("{s}s")
15 }
16}