diff --git a/src/clock.rs b/src/clock.rs index bd7420b..0bdb49f 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -222,7 +222,7 @@ impl Clock { ) -> anyhow::Result<()> { let tick_rate = std::time::Duration::from_millis(100); let mut last_tick = Instant::now(); - let mut uidata: Data = Data::new(self.timebar_len().unwrap()); + let mut uidata: Data = Data::new(self.timebar_len()); self.setup()?; loop { let raw_time = chrono::Local::now().round_subsecs(0); diff --git a/src/clock/ui.rs b/src/clock/ui.rs index 6f7d09a..97960d5 100644 --- a/src/clock/ui.rs +++ b/src/clock/ui.rs @@ -19,14 +19,14 @@ pub struct Data { ftime: [String; 2], timebar_ratio: [Option; 2], - timebar_type: TimeBarLength, + timebar_type: Option, started_at: DateTime, idx: usize, } impl Data { - pub fn new(timebar_type: TimeBarLength) -> Self { + pub fn new(timebar_type: Option) -> Self { let mut this = Self { now: [DateTime::default(); 2], fdate: [String::new(), String::new()], @@ -91,7 +91,7 @@ impl Data { #[inline] #[allow(clippy::missing_const_for_fn)] // no it's not const pub fn timebar_ratio(&self) -> Option { - if self.timebar_type == TimeBarLength::Timer { + if self.timebar_type.is_some() && self.timebar_type.unwrap() == TimeBarLength::Timer { return Some(0.0); } self.timebar_ratio[self.idx] diff --git a/src/main.rs b/src/main.rs index 679b2c4..99ef68e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,7 +90,7 @@ fn mock_tests() { info!("0s=0.0"); } { - let mut data = Data::new(clock::timebar::TimeBarLength::Day); + let mut data = Data::new(None); let now = Local::now(); data.update(now, "date".to_owned(), "time".to_owned(), Some(0.1)); assert_eq!(data.timebar_ratio(), Some(0.1));