Skip to content

Option eraDisplay in Intl.DateTimeFormat() #426

Open
@Louis-Aime

Description

@Louis-Aime

With the versions of Intl.DateTImeFormat currently (April 2020) implemented in Firefox and Chrome, with most locales, for all calendar other than gregorian, chinese and dangi, a date with a year component shall be displayed with the era component, even if not wanted by the programmer:

let t = new Date("2020-04-04");
var dtf = new Intl.DateTimeFormat(
"en-u-ca-coptic", {year : "numeric", month : "long", day : "numeric"});
dtf.format(t);  // "Baramhat 26, 1736 ERA1"

For the coptic calendar and for years after 284 AD, displaying the era is unnecessary. Moreover, the name of the era is not even properly defined in CLDR for "en", so it would be better to hide it.

On the other hand, it is a current practise to display the era only if the date displayed is not the present era. For instance:

  • it is necessary to display BC in the julian calendar for dates before 1/1/1, because years before 1 are counted backwards: year 1 BC is before 1 AD. So 21 Apr 753 designates some date in the life of Charlemagne, whereas Rome's foundation date should be written 21 Apr 753 BC.
  • in the Japanese calendar, we can forget the era for the Reiwa era, but we better mention it for Heisei dates, even more for Showa and more ancient eras.

This proposal is to add a new field for the option object of Intl.DateTimeFormat|.
This field eraDisplay may have the following values:

  • never: the era is not displayed, whatever the value of the era field may be.
  • always: the era is displayed. If necessary, the era field is set to short.
  • past: the era is displayed only if the year option is defined and the era is different from the present one; or, only if the year option is defined and a (new) qualifier hidden is not present for that era in the CLDR.

The default value of this field would be past.

Note however that, if the years before the origin are on a relative scale like in the indian calendar or the iso8601 proleptic Gregorian calendar, the years are given with a "-" sign and the era remains the same: Saka era for the indian calendar, CE for the proleptic Gregorian calendar. The same holds for all islamic calendars, for the ethiopic-amete-alem and many others.

This eraDisplay option field would give a more efficient control over the era component of the date.

Metadata

Metadata

Assignees

Labels

c: datetimeComponent: dates, times, timezoness: in progressStatus: the issue has an active proposal

Type

No type

Projects

Status

Previously Discussed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions