ecma402 icon indicating copy to clipboard operation
ecma402 copied to clipboard

Normative: Don't add default formatting to lone timeZoneName

Open ptomato opened this issue 10 months ago • 5 comments

Previously, if timeZoneName was given by itself in the formatting options, the default formatting for the other date/time components would be added. This is inconsistent with what we do for dayPeriod where a lone dayPeriod produces formats such as "in the afternoon".

The use case of obtaining the localized time zone name in all its possible variants such as specific/generic, has been mentioned several times.

This change makes a lone timeZoneName be passed to the format matcher algorithm without added date/time components, and requires implementations to have at least a year-month-day-hour-minute-second-timeZoneName format available.

See: #461

ptomato avatar Feb 07 '25 00:02 ptomato

See #957 for a similar change for era.

ptomato avatar Feb 07 '25 00:02 ptomato

I believe that the following code has worked since Intl 1.0, and it seems like a reasonable thing to write:

new Date().toLocaleTimeString("en", { timeZoneName: "long" })
'12:56:33 PM Pacific Daylight Time'

sffc avatar Jun 09 '25 19:06 sffc

Yes, it's not unreasonable to write, it's just that it's inconsistent with every other options property.

> new Date().toLocaleString(undefined, { hour: 'numeric' })
'10 a.m.'
> new Date().toLocaleString(undefined, { month: 'long' })
'June'

ptomato avatar Jun 24 '25 17:06 ptomato

Yes, I agree that I think this was a questionable design choice. It's only that the bar for changing a feature that has been working for 10 years is high, and "it seems like a reasonable thing to write" is unlikely to meet that bar. It would have to be "this seems extremely unlikely to have happened and here's some data to back that up." 😔

sffc avatar Jun 24 '25 18:06 sffc

It's somewhere on my to-do list to investigate if there is such data, but it's not a high priority right now.

ptomato avatar Jun 24 '25 18:06 ptomato

TG2 discussion: https://github.com/tc39/ecma402/blob/main/meetings/notes-2025-07-17.md#normative-dont-add-default-formatting-to-lone-timezonename-958

I'm seeking agreement on the following proposed conclusion:

We feel that the proposed behavior is better, but we are skeptical that making this change would not break the web. If we see evidence to the contrary, we can revisit. But, we are confident enough in our skepticism that we intend to close this pull request and explore other avenues for supporting standalone time zone and era formatting, which was the original motivation for the pull request.

sffc avatar Jul 17 '25 22:07 sffc

TG2 agreed to the above conclusion.

https://github.com/tc39/ecma402/blob/main/meetings/notes-2025-08-14.md#normative-dont-add-default-formatting-to-lone-timezonename-958

sffc avatar Aug 15 '25 04:08 sffc