From 9682ebaa8b82fcb6acd3e57db8ae2ca37197252d Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Fri, 27 Oct 2023 15:31:16 +0200 Subject: [PATCH] sum total wasted time --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 978ee17..80573d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,16 +56,19 @@ fn print_day() -> Option<()> { let history = fs::read_to_string("compiler_history.txt").unwrap_or_default(); let mut wasted = 0; + let mut wasted_today = 0; for line in history.lines() { let (time, duration) = line.split_once(':')?; let time: i64 = time.parse().ok()?; let duration: i64 = duration.parse().ok()?; let date = NaiveDateTime::from_timestamp_millis(time)?; + wasted += duration; if date.date() == today.date() { - wasted += duration; + wasted_today += duration; } } - println!("Total wasted today: {}", printable_time(wasted)); + println!("Total wasted today: {}", printable_time(wasted_today)); + println!("Total wasted: {}", printable_time(wasted)); Some(()) }