print start date

This commit is contained in:
Crispy 2023-11-02 13:37:40 +01:00
parent 9682ebaa8b
commit e3ea2bd396

View file

@ -57,6 +57,7 @@ fn print_day() -> Option<()> {
let mut wasted = 0;
let mut wasted_today = 0;
let mut first_date = String::new();
for line in history.lines() {
let (time, duration) = line.split_once(':')?;
let time: i64 = time.parse().ok()?;
@ -66,9 +67,12 @@ fn print_day() -> Option<()> {
if date.date() == today.date() {
wasted_today += duration;
}
if first_date.is_empty() {
first_date = format!("{:?}", date)[..10].to_owned();
}
}
println!("Total wasted today: {}", printable_time(wasted_today));
println!("Total wasted: {}", printable_time(wasted));
println!("Since {}: {}", first_date, printable_time(wasted));
Some(())
}