Repository navigation
fix: format dates with an unknown system timezone - #101
Open
pavel-klimov wants to merge 3 commits into
Open
pavel-klimov wants to merge 3 commits into
pavel-klimov wants to merge 3 commits into
Conversation
korvin89
reviewed
Oct 16, 2026
korvin89
left a comment
Collaborator
There was a problem hiding this comment.
🤖 AI generated
This review was done with AI assistance. I validated every comment myself, but the wording — including the points I found myself — was written by the AI.
Severity legend
- 🔴 blocker — should be fixed before merge.
- 🟠 should-fix — a real problem; worth fixing before or right after merge. If you can't get to it now, please open an issue and leave a comment linking it.
- 🔵 nit — minor; author's discretion.
- ❓ question — I need more context; not necessarily a defect.
Findings outside the diff
src/timeZone/timeZone.ts:9— 🟠 should-fix — This PR fixes the symptom informat.ts, but the source isguessUserTimeZone()(public export insrc/index.ts:9) and thetimeZone()getter (src/dateTime/dateTime.ts:138), which still returnEtc/Unknown. Common "read the zone and pass it back" flows still throwInvalidZone:date.timeZone(date.timeZone()),dateTime({timeZone: guessUserTimeZone()}),settings.setDefaultTimeZone(guessUserTimeZone()).timeZoneOffset(guessUserTimeZone(), ts)returnsNaN.
If handling these paths is intentionally out of scope for this PR, please state that in the PR description and document the behavior in the JSDoc of guessUserTimeZone (and the timeZone() getter): the returned value may be an invalid zone ID such as Etc/Unknown and should be validated with isValidTimeZone before being passed back. Otherwise, normalize in guessUserTimeZone itself so the other paths stop throwing as well.
Collaborator
|
@ValeraS could u take a look please? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the browser reports
Etc/Unknownas its system time zone, formatting a date withzorzzthrowsInvalidZoneand can break rendering.Use the date's numeric UTC offset to format a localized time zone label through Intl, preserving the distinction between short and long names. Engines without support for offset time zones fall back to a numeric label such as
GMT+03:00. Valid time zone names keep their existing formatting, and explicitly supplied invalid time zones are still rejected during date creation.Added regression tests for an unknown system time zone, French labels, zero offset, engines without offset-zone support, and explicit time zones. Offset formatting reuses the same helper as the
Ztoken.Scope
This PR handles date formatting only.
guessUserTimeZone()and thetimeZone()getter still return the zone reported by Intl, which may be an invalid ID such asEtc/Unknown. Their JSDoc now documents that callers must validate the result withisValidTimeZonebefore passing it todateTime, thetimeZonesetter,timeZoneOffset, orsettings.setDefaultTimeZone. Normalizing these public API results and handling time zones sent to a server are outside this change.Tests
npm test -- --runInBand— 526 tests passed on Node 18 and Node 24npm run typechecknpm run lint— passes with 7 existing warnings in unchanged files