ecma402
ecma402 copied to clipboard
Negative Gregorian years do not render by default in DateTimeFormat
In Chrome and Firefox, the following code loses the sign of the year.
new Date(-753, 5, 21).toLocaleDateString()
// "6/21/754"
My expected output would be for the Gregorian calendar to apply an era format automatically, producing "6/21/754 BC".
CC @FrankYFTang @jswalden @anba @justingrant
The reason is era is not specified.
The reason is era is not specified.
I get that; specifying era will work around the issue. The bug is that DateTimeFormat is taking a date which has a negative year, and is formatting it without any sign that it is negative. This is an incorrect result. DateTimeFormat should force the era field to be displayed when the year is negative, just like it forces the era field in the Japanese calendar and the day period field when a 12-hour clock is used.
Let me mention the link with #426. In current life, when you mention a date, you do not specify "AD" or "Common Era", whereas you do when the year is before origin. The display tools (toString) and the formatting tools ( Intl.DateTimeFormat.format() ) should do the same.
This issue is covered by the eraDisplay proposal.