Skip to content

Commit

Permalink
Treat time in seconds as an integer for download times
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Mar 9, 2019
1 parent 5bdc803 commit 1a88af0
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/rustup-cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,29 +172,26 @@ impl fmt::Display for HumanReadable {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {
// repurposing the alternate mode for ETA
let sec = self.0;
let sec = self.0 as u32;

if sec.is_infinite() {
write!(f, "Unknown")
} else if sec > 48. * 3600. {
let sec = self.0;
let d = sec / (24. * 3600.);
let h = sec % (24. * 3600.);
let min = sec % 3600.;
let sec = sec % 60.;
} else if sec > 48 * 3600 {
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;
let h = sec / 3600.;
let min = sec % 3600.;
let sec = sec % 60.;
} else if sec > 6_000 {
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;
let min = sec / 60.;
let sec = sec % 60.;
} else if sec > 100 {
let min = sec / 60;
let sec = sec % 60;

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

0 comments on commit 1a88af0

Please sign in to comment.