Bug 275489

Summary: [JSC] Fix `Intl.DurationFormat` for `numeric` and `2-digit`
Product: WebKit Reporter: Sosuke Suzuki <sosuke>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Sosuke Suzuki
Reported 2024-06-14 08:42:44 PDT
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. [1]: https://tc39.es/proposal-intl-duration-format/#sec-partitiondurationformatpattern
Attachments
Sosuke Suzuki
Comment 1 2024-06-14 08:43:51 PDT
Radar WebKit Bug Importer
Comment 2 2024-06-21 08:46:31 PDT
EWS
Comment 3 2024-06-28 10:42:58 PDT
Committed 280460@main (471838036efe): <https://commits.webkit.org/280460@main> Reviewed commits have been landed. Closing PR #29823 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.