burn_central_cli/tools/
time.rs

1use std::time::Duration;
2
3pub fn format_elapsed_time(elapsed: Duration) -> String {
4    let total_seconds = elapsed.as_secs();
5    let millis = elapsed.subsec_millis();
6
7    if total_seconds >= 3600 {
8        let hours = total_seconds / 3600;
9        let minutes = (total_seconds % 3600) / 60;
10        let seconds = total_seconds % 60;
11        format!("{}h {}m {}s", hours, minutes, seconds)
12    } else if total_seconds >= 60 {
13        let minutes = total_seconds / 60;
14        let seconds = total_seconds % 60;
15        format!("{}m {}s", minutes, seconds)
16    } else if total_seconds > 0 {
17        format!("{}s", total_seconds)
18    } else {
19        format!("{}ms", millis)
20    }
21}