Closed Bug 1568134 Opened 5 years ago Closed 5 years ago

Add fractionalSecondDigits option to Intl.DateTimeFormat

Categories

(Core :: JavaScript: Internationalization API, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: anba, Assigned: anba)

References

()

Details

(Keywords: dev-doc-needed)

Attachments

(1 file)

The spec PR https://github.com/tc39/ecma402/pull/347 adds support for the "fractionalSecondDigits" option to Intl.DateTimeFormat.

Example:

js> new Intl.DateTimeFormat("en", {second:"numeric", fractionalSecondDigits:3}).format(new Date("2019-07-23T00:00:00.123")) 
"0.123"
js> new Intl.DateTimeFormat("en", {second:"numeric", fractionalSecondDigits:2}).format(new Date("2019-07-23T00:00:00.023")) 
"0.02"

Nightly-only for now until the open spec issues are addressed.

Drive-by change:
Implement the "unknown" parts change from https://github.com/tc39/ecma402/pull/245.

Pushed by nbeleuzu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/74572aae39b0
Add support for "fractionalSecondDigits" option to Intl.DateTimeFormat. r=jwalden

Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
Blocks: 1645107

As of today with Firefox 81.0 (64 bits) for Windows: fractionalSecondDigits option of Intl.DateTimeFormat does not work.
On console:
D = new Date(Date.UTC(2020,8,15,12,15,30,550));
F = new Intl.DateTimeFormat("en-GB",{second : "numeric", fractionalSecondDigits : "3"});
F.format(D); // => 30, should be 30.550

The very same sequence works on MS Edge and Chrome.

It's enabled in nightly builds only right now. Bug 1645107 will enable it in shipping builds.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: