-
Notifications
You must be signed in to change notification settings - Fork 5k
Bump WebKit: omit dayPeriod from Intl.DateTimeFormat resolvedOptions for bare 12-hour patterns #36361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robobun
wants to merge
1
commit into
main
Choose a base branch
from
farm/e88055a8/intl-dayperiod-resolvedoptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+38
−1
Open
Bump WebKit: omit dayPeriod from Intl.DateTimeFormat resolvedOptions for bare 12-hour patterns #36361
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 nit: This test hardcodes the CLDR-derived literals
"10:05 AM"andp.value === "AM"under plaintest(), while every other exact-output check in this file is gated bysnapshotIfper the file header (macOS links Apple's libicucore, Windows a different ICU build). The invariants actually under test are CLDR-independent — consider assertingroundTrip: a.format(t)(equality, not a literal) and locating the formatToParts entry byp.type === "dayPeriod"rather than by value.Extended reasoning...
What this is
The new test at
test/js/web/intl/intl.test.ts:99-123runs on every platform (plaintest()) and asserts two CLDR-derived literals:original: "10:05 AM"/roundTrip: "10:05 AM"in the.toEqualobject, and.find(p => p.value === "AM")in the formatToParts check. This file's own header states that exact Intl output is CLDR-version-specific — "macOS uses Apple's libicucore and Windows is on a different ICU build, so snapshot diffs there are expected and not a regression" — andscripts/build/deps/webkit.tsconfirms darwin uses system ICU (prebuiltIcuLibsreturns[]for darwin, commented// darwin: system ICU). Every other exact-format-string check in this file is accordingly gated behindsnapshotIf(Linux +process.versions.icu === "75.1"only); this test bypasses that gate.Step-by-step: how a divergence would manifest
libicucorethe OS ships — its CLDR data version is not pinned by Bun and drifts per macOS release.Intl.DateTimeFormat("en-US", { hour: "numeric", minute: "2-digit" })resolves its output pattern from that CLDR data. The en time patterns have changed across ICU releases — most notably CLDR 42 (ICU 72) switched the space before the AM/PM marker to U+202F NARROW NO-BREAK SPACE, and CLDR 43 reverted it.10:05+ U+0020 +AM, the.toEqual({ ..., original: "10:05 AM", roundTrip: "10:05 AM" })assertion fails..find(p => p.value === "AM")returnsundefinedif the day-period value string differs at all (e.g. lowercase, or with a trailing marker), soundefined?.typeyieldsundefinedand.toBe("dayPeriod")fails — with a much less informative message than finding by type would give.Why this is a nit, not a blocker
Two mitigations make current-CI failure unlikely. First, JSC's
IntlDateTimeFormatnormalizes U+202F → U+0020 in its output (replaceNarrowNoBreakSpaces, a WebKit web-compat change) — verified empirically that Bun on Linux ICU 75.1 emits codepoints[31 30 3a 30 35 20 41 4d]even though raw CLDR 45 data uses NNBSP, and that normalization is C++-side so it applies on macOS too. Second, en-US"AM"is among the most stable strings in CLDR history. There is also precedent in this file for ungatedtest()with ICU-backed exact strings (thetrdotted-i case andgetCanonicalLocales), sosnapshotIfis a convention for multi-locale format sweeps rather than a hard rule. Net: fragile to future macOS ICU drift and inconsistent with the file's documented convention (REVIEW.md: "Copy harness conventions exactly"), but not demonstrably failing today.Suggested fix
The invariants the WebKit change guarantees —
ro.dayPeriod === undefined,ro.hourCycle === "h12",a.format(t) === b.format(t), and the AM/PM part's.type === "dayPeriod"— are all CLDR-independent. Rewriting the two fragile spots removes the uncontrolled-ICU dependency without weakening what's tested:Alternatively, keep the
"10:05 AM"literal but wrap that one assertion insnapshotIflike the rest of the file.