fix: period tracker day count off by one due to timezone mismatch
ongoingDay compared today (local time with hours) against startDate parsed as UTC midnight, causing Math.floor to undershoot by 1 day. Use todayMidnight and parseLocal to normalize both to local midnight.
This commit is contained in:
@@ -246,8 +246,8 @@
|
||||
// Days into current period
|
||||
const ongoingDay = $derived.by(() => {
|
||||
if (!ongoing) return 0;
|
||||
const start = new Date(ongoing.startDate);
|
||||
return Math.floor((today.getTime() - start.getTime()) / 86400000) + 1;
|
||||
const start = parseLocal(ongoing.startDate);
|
||||
return Math.floor((todayMidnight - start) / 86400000) + 1;
|
||||
});
|
||||
|
||||
// Calendar data
|
||||
|
||||
Reference in New Issue
Block a user