Skip to content

Comments

fix: skip native Date fast path when local timezone is overridden via setLocalTimeZone#9678

Merged
reidbarber merged 3 commits intoadobe:mainfrom
apoorvdarshan:fix/setLocalTimeZone-incorrect-conversion
Feb 20, 2026
Merged

fix: skip native Date fast path when local timezone is overridden via setLocalTimeZone#9678
reidbarber merged 3 commits intoadobe:mainfrom
apoorvdarshan:fix/setLocalTimeZone-incorrect-conversion

Conversation

@apoorvdarshan
Copy link
Contributor

Summary

Test plan

  • Added 3 new tests in conversion.test.js covering:
    • getTimeZoneOffset returns correct offset when local timezone is overridden
    • toAbsolute returns correct result when local timezone is overridden
    • resetLocalTimeZone restores the native Date fast path
  • All 372 existing tests in @internationalized/date continue to pass

@LFDanLu
Copy link
Member

LFDanLu commented Feb 20, 2026

Thank you for the PR! I think the code changes and tests look good, but it seems @sonsu-lee has also submitted a PR with similar changes. I'll leave it to you two to decide how yall want to proceed from here since these came in at roughly the same time haha.

As an aside, I'd would like the queries tests from #9680 to also make it in just for completeness.

@apoorvdarshan
Copy link
Contributor Author

Thanks for the review @LFDanLu! I've pushed updates addressing your feedback:

Regarding @sonsu-lee's PR #9680 — it looks like we both arrived at the same solution independently, which is great validation of the approach! I submitted this one ~30 minutes earlier, but happy to defer to whatever you and the team prefer. If there's anything from #9680 you'd like incorporated here that I'm still missing, just let me know.

@sonsu-lee
Copy link
Contributor

Thanks for the review @LFDanLu. Funny that @apoorvdarshan and I ended up with basically the same fix. #9678 was first and already has your feedback addressed, so I'll close this one. Nice work @apoorvdarshan!

@apoorvdarshan
Copy link
Contributor Author

Thanks @sonsu-lee, appreciate the kind words and for closing yours in favor of this one! Great minds think alike 😄

@LFDanLu all feedback has been addressed and CI is green now — let me know if there's anything else needed.

… setLocalTimeZone

When setLocalTimeZone is called with a timezone different from the browser's,
the fast paths in getTimeZoneOffset and toAbsolute incorrectly use native Date
(which always reflects the browser timezone) instead of the Intl-based path.
This causes incorrect offset calculations for the overridden timezone.

Skip the native Date fast paths when setLocalTimeZone has been called, falling
back to the correct Intl.DateTimeFormat-based computation.

Fixes adobe#9669
…es tests

- Fix alphabetical import sorting in conversion.ts
- Export isLocalTimeZoneOverridden from public index
- Add isLocalTimeZoneOverridden unit tests in queries.test.js as requested
@apoorvdarshan apoorvdarshan force-pushed the fix/setLocalTimeZone-incorrect-conversion branch from 4f342f2 to 59af4e2 Compare February 20, 2026 14:48
Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you @apoorvdarshan and @sonsu-lee both! I'll see about getting another pair of eyes on this

@reidbarber reidbarber added this pull request to the merge queue Feb 20, 2026
Merged via the queue into adobe:main with commit daafdd5 Feb 20, 2026
29 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.

setLocalTimeZone if used and different from the browser time zone, causes date time conversion to be incorrect when converting the local timezone

4 participants