Fix Timezone Handling in Commit Timestamps for Consistent Time-of-Day Metrics - #8994
Conversation
|
@nishtha-agarwal-211 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request addresses the issue of inconsistent timezone handling in commit timestamps, which is crucial for accurate time-of-day metrics. It builds on previous decisions to improve timezone logic and ensure consistent behavior across different environments. Notably, it aligns with the rationale behind the earlier decision to switch to |
There was a problem hiding this comment.
Pull request overview
Updates CommitPulse’s date helper logic to make time-of-day metrics deterministic across environments by avoiding system-local timezone hour extraction for commit timestamps.
Changes:
- Adjust
processCommitTimestampsto compute hours usinggetAuthorLocalHourfor ISO strings and UTC hours forDateinputs. - Update unit tests to use explicit UTC (
Z) timestamps to prevent timezone-dependent failures.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| utils/dateHelpers.ts | Updates hour extraction in processCommitTimestamps to avoid relying on system-local timezone behavior. |
| utils/dateHelpers.test.ts | Normalizes test inputs to UTC (Z) timestamps and updates regression wording for timezone consistency. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const hour = | ||
| typeof dateItem === 'string' ? getAuthorLocalHour(dateItem) : dateItem.getUTCHours(); |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Description
Fixes #8964
Updated
processCommitTimestampsinutils/dateHelpers.tsto extract hours usinggetAuthorLocalHourfor ISO string inputs andgetUTCHours()forDateobjects, rather than relying on browser/system localdate.getHours(). This ensures consistent, timezone-agnostic calculation of time-of-day metrics (morning,afternoon,evening,night) regardless of the execution environment or local machine's timezone setting.Pillar
Visual Preview
N/A (Backend utility logic & unit test optimization)
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.