Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 471838036efeaf4fd8203d543bdc8c707248606d https://github.com/WebKit/WebKit/commit/471838036efeaf4fd8203d543bdc8c707248606d Author: Sosuke Suzuki <aosuk...@gmail.com> Date: 2024-06-28 (Fri, 28 Jun 2024)
Changed paths: A JSTests/stress/intl-durationformat-numeric-auto-and-zero.js M JSTests/test262/expectations.yaml M Source/JavaScriptCore/runtime/IntlDurationFormat.cpp Log Message: ----------- [JSC] Fix `Intl.DurationFormat` for `numeric` and `2-digit` https://bugs.webkit.org/show_bug.cgi?id=275489 Reviewed by Ross Kirsling and Yusuke Suzuki. In the current JSC `Intl.DurationFormat` implementation, only units with a value that is not 0 or a display setting that is not `auto` are formatted. However, this behavior is incorrect according to the current spec[1]. When a unit's style is `numeric` or `2-digit` (i.e., the unit is `hours`, `minutes`, or `seconds`), it needs to be formatted even if its value is 0 and its display is set to auto. For example, consider the following code: ``` const df = new Intl.DurationFormat("en", { hours: "numeric", minutesDisplay: "auto", secondsDisplay: "auto" }); print(df.format({ hours: 0, minutes: 0, seconds: 1 })); ``` This code is expected to output `0:00:01`, but the current JSC outputs `0, 01`. Only the hours and seconds are displayed, while the minutes are not. Additionally, the separator `:` is not used; instead, `,` is outputted. This patch fixes this behavior and includes refactoring. [1]: https://tc39.es/proposal-intl-duration-format/#sec-partitiondurationformatpattern * JSTests/stress/intl-durationformat-numeric-auto-and-zero.js: Added. (assertSameValue): * JSTests/test262/expectations.yaml: * Source/JavaScriptCore/runtime/IntlDurationFormat.cpp: (JSC::collectElements): Canonical link: https://commits.webkit.org/280460@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes