Skip to content

Conversation

@martijnrusschen
Copy link
Member

@martijnrusschen martijnrusschen commented Dec 4, 2025

Summary

Fixes #6105

This PR fixes a bug where holidays specified as ISO date strings (e.g., "2025-01-01") would display on the wrong day in timezones west of UTC.

The Problem

When holiday dates are provided as ISO date strings (YYYY-MM-DD), the previous implementation used new Date(string) to parse them. Per JavaScript specification, ISO date strings without a time component are parsed as UTC midnight.

Later, when the date is formatted using date-fns's format() function, it converts the date to the local timezone. This causes the date to shift backward by one day for users in timezones west of UTC.

Example of the bug:

  • Input: "2025-01-01"
  • Parsed as: 2025-01-01T00:00:00.000Z (UTC midnight)
  • In PST (UTC-8): 2024-12-31T16:00:00.000-08:00
  • Result: Holiday displays on December 31st instead of January 1st

The Fix

The fix uses the existing parseDate utility function with the "yyyy-MM-dd" format. This leverages date-fns's parse function which treats the date string as local time rather than UTC, ensuring holidays display on the intended date regardless of timezone.

Before:

const date = new Date(holiday.date);

After:

const date = parseDate(holiday.date, "yyyy-MM-dd", undefined, false);

@martijnrusschen martijnrusschen changed the title fix: parse holiday date strings as local time to prevent timezone shift Draft: fix: parse holiday date strings as local time to prevent timezone shift Dec 4, 2025
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.23%. Comparing base (8279f2f) to head (f7c928e).
⚠️ Report is 46 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6106   +/-   ##
=======================================
  Coverage   99.23%   99.23%           
=======================================
  Files          30       30           
  Lines        3649     3649           
  Branches     1578     1574    -4     
=======================================
  Hits         3621     3621           
  Misses         27       27           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

When holiday dates are provided as ISO date strings (YYYY-MM-DD), the
previous implementation used `new Date(string)` which parses them as UTC
midnight. This caused holidays to display on the wrong day in timezones
west of UTC.

For example, "2025-01-01" would be parsed as 2025-01-01T00:00:00.000Z,
which when formatted in PST (UTC-8) becomes December 31st, 2024.

This fix uses the existing `parseDate` utility with the ISO format,
which uses date-fns's `parse` function that treats dates as local time.

Fixes #6105

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@martijnrusschen martijnrusschen force-pushed the fix/issue-6105-timezone-holiday-parsing branch from e38175f to f7c928e Compare December 4, 2025 19:16
@martijnrusschen martijnrusschen changed the title Draft: fix: parse holiday date strings as local time to prevent timezone shift fix: parse holiday date strings as local time to prevent timezone shift Dec 4, 2025
@martijnrusschen martijnrusschen merged commit 7790e13 into main Dec 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Holidays break when local timezone is behind UTC

2 participants