fix: Use user's local timezone for streak date calculations#1806
Conversation
|
@Pratikshya32 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):
|
|
This PR has merge conflicts with |
|
This PR cannot be merged because it branches from a significantly outdated version of To get your contribution merged:
Labeling your contribution for GSSoC scoring. |
Adds timezone-aware date utility to prevent streak miscalculation for users in non-UTC timezones. All streak comparisons now use the user's local date, not UTC midnight. Changes: - Added src/lib/dates/streakDateUtils.ts with: - getLocalDateString(): Get current date in user's timezone - utcToLocalDate(): Convert UTC timestamps to local date strings - areConsecutiveDays(): Check consecutive days timezone-aware - calculateStreak(): Timezone-aware streak calculation Fixes: Users losing streaks at midnight UTC when in different timezones
963f276 to
f9564c2
Compare
|
Hi @Priyanshu-byte-coder! Thank you for the detailed review! I have addressed all the concerns: What was fixedThe PR branch ix/streak-timezone-fix has been rebased and cleaned up:
Changes in this PR (now clean)Only 1 file added — src/lib/dates/streakDateUtils.ts:
This should now be merge-ready. Please take a look and let me know if any further changes are needed! |
9db17cd
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
Adds a timezone-aware date utility for streak calculations. Prevents users in non-UTC timezones from incorrectly losing their streak at midnight UTC.
Changes
src/lib/dates/streakDateUtils.tscc @Priyanshu-byte-coder