fix(wrapped): use tz parameter for default year calculation#6243
Conversation
The default year (when customYear is not provided) was calculated using the server's local timezone via new Date().getFullYear(), even though the route already accepts and uses a tz parameter for timezone-aware data fetching elsewhere in the same handler. This caused a mismatch near year boundaries for users in timezones different from the server. Now uses Intl.DateTimeFormat with the provided tz, consistent with the pattern in app/api/streak/route.ts. Closes JhaSourav07#6242
|
Someone is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod-Dev
left a comment
There was a problem hiding this comment.
Excellent fix. Falling back to the server's local timezone instead of the user's tz parameter for the default year calculation was a subtle bug. Using Intl.DateTimeFormat in app/api/wrapped/route.ts is the correct approach to maintain cross-timezone accuracy near the New Year boundary. Approved!
|
🎉 Congratulations @nishupr! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
Description
Fixes #6242
In
app/api/wrapped/route.ts, the default year (used whencustomYearis not provided) was calculated using the server's local timezone:However, the same route already accepts and uses a
tzparameter for fetching timezone-aware wrapped stats elsewhere in the handler:Problem with the old approach:
app/api/streak/route.tsusesIntl.DateTimeFormatwith an explicit timezone for the equivalent calculationWhat this PR does:
tzparameter (when provided) to compute the default year viaIntl.DateTimeFormat, consistent withapp/api/streak/route.tsnew Date().getFullYear()only when notzis suppliedAfter:
Pillar
Visual Preview
No visual changes — this is a timezone correctness fix.
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.