Bug 275489
| Summary: | [JSC] Fix `Intl.DurationFormat` for `numeric` and `2-digit` | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Sosuke Suzuki <sosuke> |
| Component: | Layout and Rendering | Assignee: | 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
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Sosuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/29823
Radar WebKit Bug Importer
<rdar://problem/130279541>
EWS
Committed 280460@main (471838036efe): <https://commits.webkit.org/280460@main>
Reviewed commits have been landed. Closing PR #29823 and removing active labels.