Open Bug 1648139 Opened 4 years ago Updated 1 years ago

Implement Intl.DurationFormat

Categories

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

enhancement

Tracking

()

Tracking Status
firefox79 --- affected

People

(Reporter: yulia, Unassigned)

References

(Blocks 1 open bug, )

Details

(Keywords: dev-doc-needed)

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)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: