Closed Bug 1648139 Opened 5 years ago Closed 10 months ago

Implement Intl.DurationFormat

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox79 --- wontfix
firefox134 --- fixed

People

(Reporter: yulia, Assigned: anba)

References

(Blocks 1 open bug, )

Details

(Keywords: dev-doc-complete, parity-chrome, parity-safari)

Attachments

(7 files, 1 obsolete file)

Intl.durationFormat is at stage 2

Summary: Intl.DurationFormat → Implement Intl.DurationFormat
Depends on: 1519167

"microseconds" and "nanoseconds" aren't sanctioned units for Intl.NumberFormat,
so we know have to differentiate between supported and sanctioned units.

ICU doesn't provide a public API to retrieve the time separator, so we have
to read it manually from the resource bundles.

Depends on D152743

Implements the Intl.DurationFormat constructor, including the
resolvedOptions() and supportedLocalesOf() methods.

Depends on D152744

The proposal has been decoupled from Temporal, so this bug no longer depends on bug 1519167.

The proposal itself is at stage 3, but there are still multiple open issues which may require a different implementation approach, e.g. formatToParts is likely to change, see https://github.com/tc39/proposal-intl-duration-format/issues/55. So maybe we should wait a bit longer until the major open issues have been resolved.

When writing the patches, I had to resort to hacks at two points:

  1. Formatting microseconds and nanoseconds units through Intl.NumberFormat isn't currently possible, so I had to bypass the check for valid unit identifiers. https://github.com/tc39/ecma402/issues/702 should help to avoid this hack.
  2. I had to be creative in formatToParts when digital formatting is used (e.g. "02:00:00.123"). The aforementioned formatToParts changes may require more hacks around Intl.ListFormat.
No longer depends on: 1519167
Severity: normal → S3
Attachment #9287039 - Attachment is obsolete: true
Attachment #9287040 - Attachment description: WIP: Bug 1648139 - Part 2: Add DateTimeFormat::GetTimeSeparator(). → WIP: Bug 1648139 - Part 1: Add DateTimeFormat::GetTimeSeparator().
Attachment #9287041 - Attachment description: WIP: Bug 1648139 - Part 3: Implement Intl.DurationFormat constructor. → WIP: Bug 1648139 - Part 2: Implement Intl.DurationFormat constructor.
Attachment #9287042 - Attachment description: WIP: Bug 1648139 - Part 4: Implement Intl.DurationFormat.prototype.format[ToParts]. → WIP: Bug 1648139 - Part 3: Implement Intl.DurationFormat.prototype.format[ToParts].
Attachment #9287043 - Attachment description: WIP: Bug 1648139 - Part 5: Add tests for Intl.DurationFormat. → WIP: Bug 1648139 - Part 4: Add tests for Intl.DurationFormat.
Attachment #9287044 - Attachment description: WIP: Bug 1648139 - Part 6: Enable test262 tests for Intl.DurationFormat. → WIP: Bug 1648139 - Part 5: Enable test262 tests for Intl.DurationFormat.
Attachment #9287046 - Attachment description: WIP: Bug 1648139 - Part 7: Re-import test262 to enable Intl.DurationFormat tests. → WIP: Bug 1648139 - Part 6: Re-import test262 to enable Intl.DurationFormat tests.
Attachment #9287047 - Attachment description: WIP: Bug 1648139 - Part 8: Update Intl.DurationFormat test262 exclusions. → WIP: Bug 1648139 - Part 7: Update Intl.DurationFormat test262 exclusions.

I've updated the WIP patches to match the current spec proposal text. Not quite yet ready for review, because there are still some open PRs which should land first.

There was an update about this proposal in the ECMA-402 meeting today. Ujjwal thinks that the remaining issues have been addressed that would block implementation here. Anba, does that sound right to you? Is there any feedback you'd like me to share with TG2?

Flags: needinfo?(andrebargull)

I can look into it. DurationFormat requires NumberFormat v3, which is currently only available in Nightly. I've prepared some patches to enable it by default, but realised too late that you're already assigned to bug 1795756. I hope you don't mind me stealing that bug.

(In reply to Dan Minor [:dminor] from comment #11)

Ujjwal thinks that the remaining issues have been addressed that would block implementation here. Anba, does that sound right to you? Is there any feedback you'd like me to share with TG2?

I've filed the following issues on the proposal bug tracker:

In addition to that, there are the following open PRs:

Flags: needinfo?(andrebargull)

Hi Anba, it looks like the issues and PRs above have been addressed (or at least closed...) This is on the agenda for the TC39 plenary next week, do you have any concerns about the proposal as it currently stands?

Flags: needinfo?(andrebargull)

I haven't kept track of the proposal. There were multiple larger refactorings since January, so I don't really know the current state of the proposal. It's possible that new bugs crept in as part of these changes, which may require more follow-up fixes. Hopefully this will all be editorial, but it's possible that more normative changes will be necessary.

Flags: needinfo?(andrebargull)
Assignee: nobody → andrebargull
Attachment #9287040 - Attachment description: WIP: Bug 1648139 - Part 1: Add DateTimeFormat::GetTimeSeparator(). → Bug 1648139 - Part 1: Add DateTimeFormat::GetTimeSeparator(). r=#platform-i18n-reviewers!
Status: NEW → ASSIGNED
Attachment #9287041 - Attachment description: WIP: Bug 1648139 - Part 2: Implement Intl.DurationFormat constructor. → Bug 1648139 - Part 2: Implement Intl.DurationFormat constructor. r=#spidermonkey-reviewers!
Attachment #9287042 - Attachment description: WIP: Bug 1648139 - Part 3: Implement Intl.DurationFormat.prototype.format[ToParts]. → Bug 1648139 - Part 3: Implement Intl.DurationFormat.prototype.format[ToParts]. r=#spidermonkey-reviewers!
Attachment #9287043 - Attachment description: WIP: Bug 1648139 - Part 4: Add tests for Intl.DurationFormat. → Bug 1648139 - Part 4: Add tests for Intl.DurationFormat. r=#spidermonkey-reviewers!
Attachment #9287044 - Attachment description: WIP: Bug 1648139 - Part 5: Enable test262 tests for Intl.DurationFormat. → Bug 1648139 - Part 5: Enable test262 tests for Intl.DurationFormat. r=#spidermonkey-reviewers!
Attachment #9287046 - Attachment description: WIP: Bug 1648139 - Part 6: Re-import test262 to enable Intl.DurationFormat tests. → Bug 1648139 - Part 6: Re-import test262 to enable Intl.DurationFormat tests. r=#spidermonkey-reviewers!
Attachment #9287047 - Attachment description: WIP: Bug 1648139 - Part 7: Update Intl.DurationFormat test262 exclusions. → Bug 1648139 - Part 7: Update Intl.DurationFormat test262 exclusions. r=#spidermonkey-reviewers!
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/123880a450b9 Part 1: Add DateTimeFormat::GetTimeSeparator(). r=platform-i18n-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/05549eed8b9d Part 2: Implement Intl.DurationFormat constructor. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/702c752df5a2 Part 3: Implement Intl.DurationFormat.prototype.format[ToParts]. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/adf12e0fd8d1 Part 4: Add tests for Intl.DurationFormat. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/bdb228dd5915 Part 5: Enable test262 tests for Intl.DurationFormat. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/8d36bf883a70 Part 6: Re-import test262 to enable Intl.DurationFormat tests. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/96fcefa9a41a Part 7: Update Intl.DurationFormat test262 exclusions. r=spidermonkey-reviewers,dminor
Regressions: 1932108

FF134 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/36917

  1. Is this also shipped? I can't see evidence of a preference, but that isn't always obvious is JS issues.
  2. As far as you know, is it fully spec compliant and complete? This is documented on MDN, but I will check that matches the spec - want to also check that it matches what FF did.
Flags: needinfo?(andrebargull)

(In reply to Hamish Willee from comment #18)

  1. Is this also shipped? I can't see evidence of a preference, but that isn't always obvious is JS issues.

It's currently restricted to Nightly builds.

  1. As far as you know, is it fully spec compliant and complete? This is documented on MDN, but I will check that matches the spec - want to also check that it matches what FF did.

Yes, the implementation is fully spec compliant and complete.

Flags: needinfo?(andrebargull)
Blocks: 1933303

Proposal advanced to Stage 4.

Regressions: es-proposals-stage-4
No longer regressions: 1932108
Regressions: 1932108
No longer regressions: es-proposals-stage-4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: