Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting of longer download times in download tracker #1547

Merged
merged 1 commit into from
Jan 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/rustup-cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,25 @@ impl fmt::Display for HumanReadable {

if sec.is_infinite() {
write!(f, "Unknown")
} else if sec > 1e3 {
} else if sec > 48. * 3600. {
let sec = self.0 as u64;
let min = sec / 60;
let sec = sec % 60;
let d = sec / (24. * 3600.);
let h = sec % (24. * 3600.);
let min = sec % 3600.;
let sec = sec % 60.;

write!(f, "{:3} days {:2} h {:2} min {:2} s", d, h, min, sec) // XYZ days PQ h RS min TU s
} else if sec > 6_000. {
let sec = self.0 as u64;
let h = sec / 3600.;
let min = sec % 3600.;
let sec = sec % 60.;

write!(f, "{:3} h {:2} min {:2} s", h, min, sec) // XYZ h PQ min RS s
} else if sec > 100 {
let sec = self.0 as u64;
let min = sec / 60.;
let sec = sec % 60.;

write!(f, "{:3} min {:2} s", min, sec) // XYZ min PQ s
} else {
Expand Down