diff options
author | Rupert Rutledge <eosis2 [at] gmail.com> | 2020-05-19 21:24:03 +0100 |
---|---|---|
committer | Rupert Rutledge <eosis2 [at] gmail.com> | 2020-05-19 21:26:25 +0100 |
commit | d897e14eae9c39c0bd64a775acbc6c5dedfbdbdc (patch) | |
tree | a5f934775f6a4978f89d33498946030754d38bf9 /src/display/components/header_details.rs | |
parent | 098af1f7befaabb5f129a4bd70a070daa411ce86 (diff) |
Use correct elapsed time when resizing the terminal
- Split the logic for determining the elapsed time into a function
as it was called in different placed in main.rs.
Diffstat (limited to 'src/display/components/header_details.rs')
-rw-r--r-- | src/display/components/header_details.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/display/components/header_details.rs b/src/display/components/header_details.rs index a3b0766..042d667 100644 --- a/src/display/components/header_details.rs +++ b/src/display/components/header_details.rs @@ -1,11 +1,11 @@ +use crate::display::{DisplayBandwidth, UIState}; +use ::std::time::{Duration, Instant}; use ::tui::backend::Backend; use ::tui::layout::{Alignment, Rect}; use ::tui::style::{Color, Modifier, Style}; use ::tui::terminal::Frame; use ::tui::widgets::{Paragraph, Text, Widget}; -use crate::display::{DisplayBandwidth, UIState}; - const SECONDS_IN_DAY: u64 = 86400; pub struct HeaderDetails<'a> { @@ -14,6 +14,14 @@ pub struct HeaderDetails<'a> { pub paused: bool, } +pub fn elapsed_time(last_start_time: Instant, cumulative_time: Duration, paused: bool) -> Duration { + if paused { + cumulative_time + } else { + cumulative_time + last_start_time.elapsed() + } +} + impl<'a> HeaderDetails<'a> { #[allow(clippy::int_plus_one)] pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) { |