deps,test: restore month name in DateTimeFormat with calendar=iso8601#63223
Open
JamBalaya56562 wants to merge 1 commit intonodejs:mainfrom
Open
deps,test: restore month name in DateTimeFormat with calendar=iso8601#63223JamBalaya56562 wants to merge 1 commit intonodejs:mainfrom
JamBalaya56562 wants to merge 1 commit intonodejs:mainfrom
Conversation
`Intl.DateTimeFormat` with `calendar: 'iso8601'` (or via the
`-u-ca-iso8601` locale extension) silently dropped the month part of
the formatted output for `dateStyle` `'medium'`/`'long'`/`'full'` and
for any explicit `month` option, leaving e.g.
new Intl.DateTimeFormat('en-US', {
dateStyle: 'full', timeStyle: 'long',
timeZone: 'UTC', calendar: 'iso8601',
}).format(new Date('2024-09-09T08:00:00Z'))
producing `"2024 9, Monday at 08:00:00 AM UTC"` instead of
`"2024 September 9, Monday at 08:00:00 AM UTC"`.
The ICU `iso8601` calendar resource bundle is intentionally empty: per
Unicode TR35 the iso8601 calendar is gregorian with ISO week-numbering
and therefore inherits gregorian symbols. ICU does not currently
provide month-name fallback for that calendar, so MMMM/MMM expansions
resolve to empty strings during pattern construction.
Use a copy of the ICU locale with `ca=gregory` for the pattern
generator and SimpleDateFormat construction. The iso8601 Calendar
instance is still produced from the original locale and attached via
`adoptCalendar`, so `resolvedOptions().calendar` continues to report
`"iso8601"` and ISO week-numbering semantics are preserved.
Refs: nodejs#63041
https://claude.ai/code/session_016L6yWKzfkf5JhyDzK5S6sC
Collaborator
|
Review requested:
|
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
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.
Fixes: #63041
Bug
Intl.DateTimeFormatwithcalendar: 'iso8601'(or with the-u-ca-iso8601locale extension) silently drops the month part of theoutput for
dateStyle'medium'/'long'/'full'and for any explicitmonthoption:The regression was introduced in v24.13.0 with the bundled ICU update.
Per Unicode TR35 the iso8601 calendar is gregorian with ISO
week-numbering and inherits gregorian symbols, but ICU's
iso8601resource bundle is intentionally empty and does not carry month-name
symbols, so MMMM/MMM expansions resolve to empty strings during pattern
construction.
Fix
In
JSDateTimeFormat::CreateDateTimeFormat, derive a copy of the ICUlocale with
ca=gregoryand use it for theDateTimePatternGeneratorand
SimpleDateFormatconstruction (and the extension-fallback retry).The iso8601
Calendarinstance is still produced from the originallocale and attached via
adoptCalendar, soresolvedOptions().calendarcontinues to report
"iso8601"and ISO week-numbering semantics arepreserved.
Reproduction
Independently reproduced against an unmodified Node v26.1.0 baseline:
https://aletheia-works.github.io/vivarium/repro/node/63041/
Tests
test/parallel/test-intl-iso8601-calendar-month.jscoveringdateStyle: 'full'/'long'/'short', explicitmonth: 'long', theexplicit field skeleton path, and
formatToPartsmonth part. Thetest fails on the pre-patch tree and passes on this branch.
make -j test-intlpasses locally on Linux/x86_64.