[webkit-changes] [WebKit/WebKit] 4bfba2: [JSC] Update Intl.DurationFormat based on Jan ECMA...
Yusuke Suzuki
noreply at github.com
Tue Jan 24 16:33:16 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 4bfba24bc18e04141df7181b750dcebea75e3845
https://github.com/WebKit/WebKit/commit/4bfba24bc18e04141df7181b750dcebea75e3845
Author: Yusuke Suzuki <ysuzuki at apple.com>
Date: 2023-01-24 (Tue, 24 Jan 2023)
Changed paths:
M JSTests/stress/intl-durationformat-format-to-parts.js
M JSTests/stress/intl-durationformat.js
M Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
M Source/JavaScriptCore/runtime/IntlDurationFormatPrototype.cpp
Log Message:
-----------
[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]: https://github.com/tc39/proposal-intl-duration-format/issues/128
[2]: https://github.com/tc39/proposal-intl-duration-format/issues/44
[3]: https://github.com/tc39/proposal-intl-duration-format/issues/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
More information about the webkit-changes
mailing list