Closed Bug 1557718 Opened 5 years ago Closed 4 years ago

Implement dateStyle and timeStyle option on Intl.DateTimeFormat

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: alex.fdm, Assigned: anba)

References

(Blocks 1 open bug, )

Details

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

Attachments

(5 files)

The specification is already on Stage 3: https://github.com/tc39/proposal-intl-datetime-style
There was a previous implementation of these on bug #1329904, but it does not seem to follow the current spec.

Priority: -- → P2
Keywords: parity-chrome

Btw. this is already implemented in SpiderMonkey for internal use (bug 1329904) - in fact the ECMA402 proposal has been kicked off by us to expose that.

So this should mostly be about exposing already existing bits to public.

See Also: → 1329904
Blocks: es-intl
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

mozExtensions is now only used for the patternOption property, because
dateStyle and timeStyle are no longer custom extensions. So instead of
testing for mozExtensions, we can simply only test if patternOptions is
present.

And update Intl_DateTimeFormat_resolvedOptions to only set the "hour12"
and "hourCycle" options when timeStyle is used.

Depends on D73892

CLDR provides date-time patterns, not skeletons, for date/time-styles, so
when either hour12 or hourCycle is present, we need to adjust the returned
pattern to use the correct hour symbol.

Drive-by change:

  • Move replaceHourRepresentation for standard options to C++.
  • Change resolveDateTimeFormatInternals to no longer change the hour
    symbol when the non-standard patternOption is used.

Depends on D73895

Pushed by cbrindusan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fcbfbb53396d
Part 1: Reduce code duplication for date/time-style parsing. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/12fe4bb1d720
Part 2: Remove "mozExtensions" flag from resolved internal options. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/97ab994e8e06
Part 3: Implement date-/timeStyle proposal. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/8118b2bfb39d
Part 4: Add hourCycle support to date/time-style. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/b9853d5eb007
Part 5: Enable test262 tests for date-/timeStyle. r=jwalden
Flags: needinfo?(andrebargull)
Pushed by btara@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/728f07ec3003
Part 1: Reduce code duplication for date/time-style parsing. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/4a973d7cbca2
Part 2: Remove "mozExtensions" flag from resolved internal options. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/dd064bac3143
Part 3: Implement date-/timeStyle proposal. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/f0a7e9cdc27c
Part 4: Add hourCycle support to date/time-style. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/ecc73e9b85b1
Part 5: Enable test262 tests for date-/timeStyle. r=jwalden

(In reply to Florian Scholz [:fscholz] (MDN) from comment #11)

Let me know if you have any feedback.

LGTM. Thanks!

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

Attachment

General

Created:
Updated:
Size: