From 0e0c709f478340ec737cbc8db3aa8f1e4729db7b Mon Sep 17 00:00:00 2001 From: Rich Haase <46830998+richhaase@users.noreply.github.com> Date: Mon, 9 Mar 2026 08:37:06 -0600 Subject: [PATCH] fix: DST boundary bug in weekly workout grouping When DST springs forward (e.g. March 8 in America/Denver), the millisecond difference between consecutive Monday midnights is ~6.96 days instead of 7.0, causing Math.floor to assign workouts to the previous week. Fix by rounding to nearest day before dividing by 7. Co-Authored-By: Claude Opus 4.6 --- src/stats.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stats.ts b/src/stats.ts index fdb768f..1b75bed 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -79,9 +79,10 @@ export function buildWeekSummaries( if (t < cutoff || t > now) continue; const monday = mondayOf(t); - const idx = Math.floor( - (monday.getTime() - cutoff.getTime()) / (1000 * 60 * 60 * 24 * 7), + const diffDays = Math.round( + (monday.getTime() - cutoff.getTime()) / (1000 * 60 * 60 * 24), ); + const idx = Math.floor(diffDays / 7); if (idx < 0 || idx >= weeks) continue; const ws = summaries[idx]!;