Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 45b638378595675f5125fd46556497b739d7c66c
      
https://github.com/WebKit/WebKit/commit/45b638378595675f5125fd46556497b739d7c66c
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-06-05 (Fri, 05 Jun 2026)

  Changed paths:
    A JSTests/stress/intl-datetimeformat-temporal-non-default-calendar.js
    M Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp

  Log Message:
  -----------
  [JSC] `Intl.DateTimeFormat` Temporal pattern generation should pass the 
calendar to ICU in BCP47 form
https://bugs.webkit.org/show_bug.cgi?id=315984

Reviewed by Yusuke Suzuki.

computeGetDateTimeFormat and computeAdjustDateTimeStyleFormat build the
locale passed to udatpg_open as dataLocale + "@calendar=" + m_calendar.
However, m_calendar holds the BCP47 calendar name (e.g. "gregory"),
while ICU's legacy @calendar= keyword expects the legacy name
(e.g. "gregorian"). For calendars whose two names differ (gregory,
ethioaa), ICU silently ignores the unknown value, and the pattern
generator falls back to the locale's default calendar.

The formatter itself still uses the requested calendar, so the
formatted field values stay correct, but the selected pattern (field
order, month style, era visibility) is the one for the wrong calendar.
This is observable with ar-SA-u-ca-gregory, whose default calendar is
islamic-umalqura: formatting a Temporal.PlainDate produces a spurious
era field and a long month name, diverging from formatting the
equivalent Date with the same DateTimeFormat instance, which goes
through a correct code path.

Fix this by appending the calendar with the -u-ca- BCP47 extension,
matching how the rest of this file builds ICU locales
(initializeDateTimeFormat, createTemporalIntervalFormat).

Test: JSTests/stress/intl-datetimeformat-temporal-non-default-calendar.js

* JSTests/stress/intl-datetimeformat-temporal-non-default-calendar.js: Added.
(shouldBe):
(hasEra):
(const.dateTime.new.Date.Date.UTC):
(fmt.format):
(shouldBe.hasEra.fmt.formatToParts):
* Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::computeAdjustDateTimeStyleFormat const):
(JSC::IntlDateTimeFormat::computeGetDateTimeFormat const):

Canonical link: https://commits.webkit.org/314687@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to