WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
293431
Incorrect date formatting in Gregorian-derived calendars before 1582
https://bugs.webkit.org/show_bug.cgi?id=293431
Summary
Incorrect date formatting in Gregorian-derived calendars before 1582
Devon Govett
Reported
2025-05-22 09:18:46 PDT
When formatting dates before 1582 in Gregorian-derived calendars such as buddhist and japanese, the month and day are incorrect. ``` new Date(1580, 0, 1).toLocaleDateString('th-TH-u-ca-buddhist') // => '22/12/2122' (incorrect) ``` As discussed in
https://github.com/tc39/ecma402/issues/1003
, all of these calendars should be defined as proleptic - meaning they extend before the Gregorian Calendar was invented in 1582. WebKit overrides ICU's default Gregorian cutover date here:
https://github.com/WebKit/WebKit/blob/c35dad9edf1cbad19d9af6749d43c7329eada970/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp#L958-L961
, however this only applies to the Gregorian Calendar itself and not to its subclasses due to this code in ICU:
https://github.com/unicode-org/icu/blob/b30c63d1b930610850489a67433b9c3ba55d6f43/icu4c/source/i18n/ucal.cpp#L298-L310
. Seems like this should be overridden for all Gregorian-based calendars. Looks like Firefox has already made this change in version 139 beta and in that version returns the correct result: ``` new Date(1580, 0, 1).toLocaleDateString('th-TH-u-ca-buddhist') // => "1/1/2123" (correct) ```
Attachments
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2025-05-23 16:48:03 PDT
Since WebKit only uses C-ICU API, unless ucal_setGregorianChange gets fixed, we cannot do much. So this is basically ICU bug
Radar WebKit Bug Importer
Comment 2
2025-05-23 16:48:41 PDT
<
rdar://problem/151952896
>
Devon Govett
Comment 3
2025-05-27 10:32:26 PDT
I'm not sure whether ICU is planning on changing their behavior, but based on the code for ucal_setGregorianChange, it seems like maybe you could cast the pointer to the equivalent C++ Calendar API and use that directly?
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug