Description
It's my understanding that ECMAScript uses the proleptic Gregorian calendar to represent dates - that is, it extends the Gregorian calendar to dates before it was invented in 1582. Formatting dates prior to 1582 works following these rules:
new Date(1580, 0, 1).toLocaleDateString('en-US')
// => '1/1/1580'
It is also my understanding that the Thai calendar ('buddhist'
) is equivalent to the Gregorian calendar, but with the years shifted by 543 years. However, when formatting a date before 1582 in the buddhist calendar, the month and day are also changed.
new Date(1580, 0, 1).toLocaleDateString('th-TH-u-ca-buddhist')
// => '22/12/2122'
The same thing happens in the Japanese calendar:
new Date(1580, 0, 1).toLocaleDateString('ja-JA-u-ca-japanese')
// => '天正7/12/22'
I believe this is because internally to ICU, there is a default Gregorian cutover date defined as October 15, 1582. This means that dates prior to this cutover are treated as if they were in the Julian calendar rather than Gregorian, e.g. following different leap year rules.
JS engines are overriding the default cutover date when formatting Gregorian dates. For example, here in WebKit, and here in V8. However, this only applies to the Gregorian calendar itself, and not to its subclasses.
So, the question is: what is the correct behavior here? Should dates in Gregorian-derived calendars such as buddhist and japanese also override the cutover to match ECMAScript's Gregorian behavior? Or should the default cutover be restored for Gregorian dates? Or is the current behavior correct?