fix(dateUtils): use local timezone in toDateStr to fix streak date bug for UTC+ users#1674
Conversation
Replace toISOString().slice(0,10) with getFullYear/getMonth/getDate so that commits made early morning in timezones ahead of UTC (IST, JST, AEDT, etc.) are logged on the correct local calendar date instead of the previous UTC date, which was breaking valid streaks.
|
@Anubrata023 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
There was a problem hiding this comment.
Thanks for your first PR on DevTrack! 🎉
A maintainer will review it within 48 hours. While you wait:
- Make sure CI is passing (type-check + lint)
- Double-check the PR description is filled out and the issue is linked
- Feel free to ask questions in Discussions if you need help
If you find DevTrack useful, a ⭐ star on the repo is always appreciated — it helps the project grow and attract more contributors!
32e9f0f
into
Priyanshu-byte-coder:main
|
🎉 Merged! Thanks for contributing to DevTrack. If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers. Keep an eye on open issues for your next contribution! |
Summary
Replace
toISOString().slice(0,10)withgetFullYear/getMonth/getDateso that commits made early morning in timezones ahead of UTC (IST, JST, AEDT, etc.) are logged on the correct local calendar date instead of the previous UTC date, which was breaking valid streaks.gssoc26
Closes #928
Type of Change
Testing
[✅] Verified fix applies correctly to all call sites
[✅] No TypeScript errors
[✅] Indentation consistent with codebase (2-space)
[✅] No other files modified
Accessibility Checklist
No UI changes in this PR — purely a data/logic fix
Root Cause
In
src/lib/dateUtils.ts, thetoDateStrfunction was usingDate.toISOString()which always outputs a UTC date string. For users in timezones significantly ahead of UTC (e.g., IST +5:30, JST +9:00, AEDT +11:00), a commit made between midnight and their UTC offset would be logged as the previous day, silently breaking an otherwise valid streak.Before (broken):