You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[JSC] Update Intl.DurationFormat based on Jan ECMA402 consensus
https://bugs.webkit.org/show_bug.cgi?id=251115
rdar://104582024
Reviewed by Mark Lam.
This patch upgrades Intl.DurationFormat implementation to align it to Jan ECMA402 meeting consensus.
The changes are three-fold.
1. format and formatToParts should accept String too. And throwing a range error when string is not valid[1].
2. formatToParts should use singular form of unit names instead of plural form.
3. formatToParts should split each unit's representation to make numeric part and unit part accessible[3]. Previously,
we just grouped "1 hour" as "hour" part. But after this, we split it into "1" integer, " " literal, and "hour" unit,
with unit = "hour".
[1]: tc39/proposal-intl-duration-format#128
[2]: tc39/proposal-intl-duration-format#44
[3]: tc39/proposal-intl-duration-format#55
* JSTests/stress/intl-durationformat-format-to-parts.js:
(Intl.DurationFormat.shouldBe.JSON.stringify.fmt.formatToParts):
(Intl.DurationFormat.shouldBeOneOf):
* JSTests/stress/intl-durationformat.js:
(test):
* Source/JavaScriptCore/runtime/IntlDurationFormat.cpp:
(JSC::collectElements):
(JSC::IntlDurationFormat::formatToParts const):
* Source/JavaScriptCore/runtime/IntlDurationFormatPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
Canonical link: https://commits.webkit.org/259317@main
Copy file name to clipboardExpand all lines: JSTests/stress/intl-durationformat-format-to-parts.js
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
//@ requireOptions("--useIntlDurationFormat=1")
2
+
//@ skip if $hostOS != "darwin" # We are testing Intl features based on Darwin's ICU. The other port owners can extend it by testing it in their platforms and removing this condition.
0 commit comments