Closed Bug 1899177 Opened 4 months ago Closed 3 months ago

Support more built-in calendars in Temporal

Categories

(Core :: JavaScript: Standard Library, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
129 Branch
Tracking Status
firefox129 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(18 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Support more built-in calendars in Temporal than just the ISO-8601 calendar.

The large files check in "vendor_rust.py" had to be manually disabled to allow
importing "third_party/rust/calendrical_calculations/src/astronomy.rs". (About 20% of
the file size is test code.)

Depends on D211762

All calendars supported by ICU4X require a strictly positive era-year. We can
easily enforce this by restricting the eraYear temporal field to be positive.

Depends on D211763

Allow other calendar identifiers than just "iso8601". Also make sure old deprecated
aliases are properly updated to their preferred form.

Depends on D211764

Implement the following operations:

  • CalendarDateMonth
  • CalendarDateDay
  • CalendarDateDayOfWeek
  • CalendarDateWeekOfYear
  • CalendarDateDaysInWeek
  • CalendarDateDaysInMonth
  • CalendarDateDaysInYear
  • CalendarDateMonthsInYear

Calendar arithmetic isn't currently supported in ICU4X through the public
API, so for now we simply default to the ISO calendar operations for:

  • CalendarDateAddition
  • CalendarDateDifference

Calendrical computations are performed through ICU4X instead of ICU4C, as
previously discussed on multiple occasions.

The Temporal spec leaves the concrete semantics of any calendar except the
ISO-8601 calendar as implementation-defined, so we're free to implement things
however we like. For better cross-engine compatibility, certain aspects should
probably clarified, though. For example in the Japanese calendar with its
regnal eras, if the user-supplied eraYear exceeds the named era, do we
constrain eraYear to the end of the era or do we alternatively switch to the
next era? Bug reports against the Temporal spec repo will be written to clarify
these points.

This patch doesn't perform any caching, so the ICU4X calendar and date types are
created from scratch for all operations. This will likely be too slow (10-100x
slow-downs when compared to using the non-ICU4X based ISO-8601 calendar), so in
a follow-up bug we likely need to investigate how to add some sort of caching.

And just as with Intl.Segmenter, we're using the ICU4X C-API instead of the
C++ API, see also https://github.com/rust-diplomat/diplomat/issues/280.

Depends on D211765

Add code to convert between Temporal and ICU4X era codes. And then implement
more calendar operations which are possible when era codes are supported.

Depends on D211766

Implement code to handle month codes and to determine which month codes are
available for the different built-in calendar types.

Depends on D211767

Add code to convert calendar dates to ISO calendar dates, including overflow behaviour
to constrain resp. reject too large values.

The complicated CreateDateFrom and CreateDateFromCodes functions are also used in
the next part.

Depends on D211769

Implement the operations to interpret user-supplied temporal fields as calendar dates.

Depends on D211770

Similar to part 10, this operation interprets user inputs as month-day information
and then resolves the matching ISO date.

Depends on D211771

Add tests for issues encountered during development of the
built-in calendar feature.

Depends on D211774

We could require ICU4X for Temporal, which will allow us to remove some
#if defined(MOZ_ICU4X) guards. See the next part.

Depends on D211775

Remove guards which aren't required anymore when ICU4X is strictly required for
Temporal.

Depends on D211776

Severity: -- → N/A
Priority: -- → P2
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/0bf2e1a23a9c Part 1: Enable "icu_calendar" feature from ICU4X. r=spidermonkey-reviewers,supply-chain-reviewers,glandium,sylvestre,mgaudet https://hg.mozilla.org/integration/autoland/rev/a30375873882 Part 1.1: Update "icu_calendar" crate. r=supply-chain-reviewers https://hg.mozilla.org/integration/autoland/rev/afa030ec8eb0 Part 2: Vendor icu_calendar and calendrical_calculations. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/854faa667cab Part 2.1: Vendor updated icu_calendar and calendrical_calculations. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/d3a840a90933 Part 3: Require eraYear temporal field to be positive. r=spidermonkey-reviewers,mgaudet https://hg.mozilla.org/integration/autoland/rev/5eb22ccbff43 Part 4: Allow creating calendars other than "iso8601". r=spidermonkey-reviewers,mgaudet https://hg.mozilla.org/integration/autoland/rev/a20785863ddd Part 5: Support simple calendar methods calling into ICU4X. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/00cc2684b43d Part 6: Implement CalendarDateEra, CalendarDateEraYear, CalendarDateYear, and CalendarDateYearOfWeek operations. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/b1a56399314f Part 7: Implement CalendarDateMonthCode and CalendarDateInLeapYear operations. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/c399d8e8970f Part 8: Implement CalendarFieldDescriptors and CalendarFieldKeysToIgnore operations. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/91b1c940f830 Part 9: Implement CalendarDateDayOfYear operation. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/3f13fe57609a Part 10: Implement CalendarDateToISO and CalendarResolveFields operations. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/0e96407ac3cc Part 11: Implement CalendarMonthDayToISOReferenceDate operation. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/126c31ada138 Part 12: Enable now passing tests. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/b63bd051f362 Part 13: Add tests for built-in calendars. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/0e73fddfdb51 Part 14: Require ICU4X for Temporal. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/7d7cd36bc5c3 Part 15: Remove MOZ_ICU4X guards when Temporal requires ICU4X. r=spidermonkey-reviewers,dminor https://hg.mozilla.org/integration/autoland/rev/1af5bef2fcd2 Part 16: Make icu_calendar an optional feature. r=firefox-build-system-reviewers,glandium
Depends on: 1899444
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: