tc39 / proposal-intl-eradisplay

Intl.DateTimeFormat displays era field only if date displayed is in same era as today's
MIT License
10 stars 4 forks source link

Resolving eraDisplay at construction time #3

Open Louis-Aime opened 3 years ago

Louis-Aime commented 3 years ago

As proposed on Dec. 8, here is the way Intl.DateTimeFormat handles eraDisplay at contruction time.

  1. As Intl.DateTimeFormat is constructed, a resolved eraDisplay field is evaluated.
    1. value is set to "never" or "always" if it was specified so.
    2. else, including if no eraDisplay was passed, value is set to "auto".
    3. except if value was set to "never", era option is set to "short" if it was undefined.
    4. finally, if "auto" and if the year option is undefined, value is set to "never".

In other words:

Please note that, as of today (and I'm not sure this is in line with the original intention), if the only asked option is era, all date parts are displayed. With the proposed option, setting era only would result in having all date fields except era !

I thought that only if all date-time option fields were undefined the day month year combination was assumed. (see e.g. in MDN As of today, it is not possible to display the era alone. Something remains to be done here ("Best fit" resolving option ?).

That said, only very demanding users having rather special requirements (displaying era and other part of the date, except year) would have to change their code.

sffc commented 1 year ago

Needs a bit more thought in order to make this work:

  1. How does it work with dateStyle?
  2. Need to make sure it aligns with the data model