Skip to content

Fix Timezone Handling in Commit Timestamps for Consistent Time-of-Day Metrics - #8994

Open
nishtha-agarwal-211 wants to merge 1 commit into
JhaSourav07:mainfrom
nishtha-agarwal-211:fix/process-commit-timestamps-timezone
Open

Fix Timezone Handling in Commit Timestamps for Consistent Time-of-Day Metrics#8994
nishtha-agarwal-211 wants to merge 1 commit into
JhaSourav07:mainfrom
nishtha-agarwal-211:fix/process-commit-timestamps-timezone

Conversation

@nishtha-agarwal-211

Copy link
Copy Markdown
Contributor

Description

Fixes #8964

Updated processCommitTimestamps in utils/dateHelpers.ts to extract hours using getAuthorLocalHour for ISO string inputs and getUTCHours() for Date objects, rather than relying on browser/system local date.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

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A (Backend utility logic & unit test optimization)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

Copilot AI lite review requested due to automatic review settings August 10, 2026 16:54
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@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.

@retenta-bot

retenta-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

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 getUTCHours() to prevent test failures in non-UTC timezones. Thank you for your contribution, and I look forward to your updates!

@retenta-bot retenta-bot Bot changed the title fix(dateHelpers): evaluate processCommitTimestamps in a timezone-agnostic manner Fix Timezone Handling in Commit Timestamps for Consistent Time-of-Day Metrics Aug 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 processCommitTimestamps to compute hours using getAuthorLocalHour for ISO strings and UTC hours for Date inputs.
  • 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.

Comment thread utils/dateHelpers.ts
Comment on lines +16 to +17
const hour =
typeof dateItem === 'string' ? getAuthorLocalHour(dateItem) : dateItem.getUTCHours();
@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 4998.89 KB 4998.89 KB 0 B
Total CSS 354.18 KB 354.18 KB 0 B

@github-actions github-actions Bot added the type:bug Something isn't working as expected label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: processCommitTimestamps fails tests in non-UTC local timezones

2 participants