Skip to content

Commit

Permalink
Add days to the duration print
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupert Rutledge committed May 9, 2020
1 parent 53b80c7 commit e17f8e6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/display/components/total_bandwidth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ impl<'a> HeaderDetails<'a> {
}

fn render_elapsed_time(&self, frame: &mut Frame<impl Backend>, rect: Rect, color: &Color) {
const SECONDS_IN_DAY: u64 = 86400;
let plural = if self.elapsed_time.as_secs() / SECONDS_IN_DAY == 1 {
""
} else {
"s"
};
let elapsed_time_text = [Text::styled(
format!(
"Duration: {:02}:{:02}:{:02} ",
"{:01} day{}, {:02}:{:02}:{:02} ",
self.elapsed_time.as_secs() / SECONDS_IN_DAY,
plural,
self.elapsed_time.as_secs() / 3600,
(self.elapsed_time.as_secs() % 3600) / 60,
self.elapsed_time.as_secs() % 60
Expand Down

0 comments on commit e17f8e6

Please sign in to comment.