From 4c854f099abdc4bb1e43b7bf57318bdd2df51179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sun, 22 Dec 2024 00:38:37 +0100 Subject: [PATCH] Start work week on Saturday --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index eb0a178..0a44413 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,7 +161,8 @@ async fn get_metrics(State(pool): State, seconds: today = today - chrono::Duration::days(1); // If we are currently tracking, we haven't started today yet } let today_start = today.and_hms_opt(0, 0, 0); - let week_start = (today - chrono::Duration::days(current_time.weekday().num_days_from_monday() as i64)).and_hms_opt(0, 0, 0); + // We start our week on Saturday, the end of the previous week + let week_start = (today - chrono::Duration::days((current_time.weekday().num_days_from_sunday() - 1) as i64)).and_hms_opt(0, 0, 0); let month_start = today.with_day(1).unwrap().and_hms_opt(0, 0, 0); let year_start = today.with_day(1).unwrap().with_month(1).unwrap().and_hms_opt(0, 0, 0);