Repository navigation
[BUG] : Timezone Mismatch Bug in Streak Freeze #2952
Description
Bug Description
A timezone mismatch between the streak metrics calculator and the streak freeze API causes users to lose their streaks even after activating a streak freeze.
The streak calculator in
route.ts (streak)
resolves the user's local timezone from the database (e.g., Asia/Kolkata) and buckets GitHub commit dates into local YYYY-MM-DD strings. However, when the user requests a streak freeze, the API in
route.ts (freeze)
generates and stores the freeze date in UTC time using new Date().toISOString().slice(0, 10).
If a user activates a streak freeze when their local calendar date differs from the UTC date, the freeze is recorded under the wrong date in the database. When the streak calculator evaluates their streak in their local timezone, it checks for a freeze on their local calendar date, fails to find it (since it was written under the UTC date), and resets their streak to 0.
I expected the streak freeze to be recorded under the user's configured local timezone date so that it applies to the correct local calendar day.
Steps to Reproduce
-
Set the user's timezone to a region that has a significant offset from UTC (e.g. Asia/Kolkata / GMT+5:30).
-
Activate a streak freeze when the local date and UTC date differ (e.g., at 1:30 AM local time on July 1st, when the UTC time is 8:00 PM on June 30th).
-
Check the streak_freezes table in the database; the freeze_date will be recorded as 2026-06-30 (UTC) instead of 2026-07-01 (Local).
-
Fetch user streak metrics via /api/metrics/streak on July 1st local time. Since no commits have been made on July 1st and the database freeze date is June 30th, the active streak will drop to 0 instead of remaining active.
Affected Area
Streak System
Screenshots
No response
Browser & OS
All Browsers & OS (Logic level issue)
Environment
None
Additional Context
In the freeze route src/app/api/streak/freeze/route.ts:
function todayStr(): string {
return new Date().toISOString().slice(0, 10); // Generates UTC YYYY-MM-DD
}
In the streak metrics route src/app/api/metrics/streak/route.ts:
// Resolves local timezone and buckets commit dates relative to user's day boundaries:
let timeZone = "UTC";
if (appUserId) {
const { data: userRow } = await supabaseAdmin
.from("users")
.select("timezone")
.eq("id", appUserId)
.single();
if (userRow?.timezone) timeZone = userRow.timezone;
}
...
const streakData = calculateStreakFromDates(activeDates, freezeDates, timeZone);
Activity
guruprasadvv commentedon Jul 1, 2026
\assign
guruprasadvv commentedon Jul 1, 2026
/assign
yachikadev commentedon Jul 1, 2026
hii i would like to work on this contributing under gssoc'26
github-actions commentedon Jul 1, 2026
Assigned to @yachikadev! You have 7 days to open a PR. No PR after 7 days = auto-unassigned so others can pick it up. Good luck!
github-actions commentedon Jul 13, 2026
✅ Closed as completed!
If DevTrack has been useful, a ⭐ star on the repo helps the project grow and reach more developers.