Closed Bug 1752253 Opened 3 years ago Closed 2 years ago

Intl.DateTimeFormat: wrong era "A" instead of "AD" for Gregorian calendar using `era: 'short'` option

Categories

(Core :: JavaScript: Internationalization API, defect, P3)

Firefox 96
defect

Tracking

()

VERIFIED FIXED
106 Branch
Tracking Status
firefox106 --- verified

People

(Reporter: justin, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:97.0) Gecko/20100101 Firefox/97.0

Steps to reproduce:

dtf = new Intl.DateTimeFormat(`en-US-u-ca-gregory`, {
  day: 'numeric',
  month: 'numeric',
  year: 'numeric',
  era: 'short',
  timeZone: 'UTC'
});
parts = dtf.formatToParts(new Date('2019-02-06T00:00Z'));
parts.filter(p => p.type === 'era')[0];

Actual results:

{ type: "era", value: "A" }

This change (from FF 95=>96) broke the Temporal polyfill which relies on the output of DateTimeFormat#formatToParts. See https://github.com/tc39/proposal-temporal/issues/2020 for more context.

I assume this is related to bug 1751833.

Expected results:

{ type: "era", value: "AD" }

The output above is what FF 95, latest Chrome 97.0.4692.99, latest Safari 15.2 (17612.3.6.1.6), and (see excerpt below) the MDN docs say should be emitted:

<dt><code>era</code></dt>
  <dd>The representation of the era. Possible values are:
  <ul>
   <li>"<code>long</code>" (e.g., <code>Anno Domini</code>)</li>
   <li>"<code>short</code>" (e.g., <code>AD</code>)</li>
   <li>"<code>narrow</code>" (e.g., <code>A</code>)</li>
  </ul>
  </dd>
Component: Untriaged → JavaScript: Internationalization API
Product: Firefox → Core
Flags: needinfo?(gtatum)

What's weird here is that Chrome v100 is not agreeing with us, even though it is with Bug 1751833.

Justin, do you have thoughts here?

Flags: needinfo?(justin)
Assignee: nobody → gtatum

I agree that the CLDR data looks wrong. "A" is the correct value for the era: 'narrow' option. Looks like a typo to use it also for era: 'short'.

Not sure why Chrome isn't agreeing, perhaps because they're patching this obvious bug in the source data, but didn't catch the subtler issue in Bug 1751833?

Flags: needinfo?(justin)
Severity: -- → S3
Priority: -- → P3

I'm unassigning myself as I'm not actively working on this, and we can circle back when CLDR-15510 is addressed to confirm the fix.

Assignee: gtatum → nobody

Just ran into this as well. Looks like both Safari and Chrome return AD/BC rather than A/B for the short style.

Blocks: 1788981

What I don't understand is why Chrome and Safari get different results, don't they also use ICU? Andre is this something you know?

Flags: needinfo?(andrebargull)

This is actually exploiting an ICU bug, but ensures we return the same results
as other browsers. When the ICU bug has been fixed, we can revert this back to
"G".

Assignee: nobody → andrebargull
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

(In reply to Tom Schuster [:evilpie] from comment #7)

What I don't understand is why Chrome and Safari get different results, don't they also use ICU? Andre is this something you know?

I tracked this down to this ICU bug https://unicode-org.atlassian.net/browse/ICU-22138. When we change the era skeleton from "G" to "GGG", the expected output is produced.

Flags: needinfo?(andrebargull)
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/21386acd4473 Change era skeleton to "GGG" to produce the expected era field length. r=platform-i18n-reviewers,gregtatum
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch

This reverts commit 47452bdfab077e1f686d4321c658824f5599c533.

Attachment #9294516 - Attachment is obsolete: true
QA Whiteboard: [qa-106b-p2]

Reproduced this issue on an affected Nightly build from 2022-01-24 (20220124093541), on macOS 10.15
Verified fixed on Firefox 106.0 (20221010110315) on macOS 10.15.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-106b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: