sync: Show time elapsed per send

This commit is contained in:
2021-10-12 18:15:50 +02:00
parent eb42576823
commit 0e583377e9
3 changed files with 31 additions and 2 deletions

14
src/util.rs Normal file
View File

@ -0,0 +1,14 @@
use std::time::Duration;
pub fn format_duration(d: Duration) -> String {
let seconds = d.as_secs_f32() % 60.0;
let minutes = d.as_secs() / 60 % 60;
let hours = d.as_secs() / 60 / 60;
match (hours, minutes) {
(0, 0) => format!("{:.2}s", seconds),
(0, _) => format!("{}m {:.2}s", minutes, seconds),
(_, 0) => format!("{}h {:.2}s", hours, seconds),
(_, _) => format!("{}h {}m {:.2}s", hours, minutes, seconds),
}
}