Bug 285078
Summary: | Intl.DurationFormat in digital style breaks the output when hoursDisplay is "auto" | ||
---|---|---|---|
Product: | WebKit | Reporter: | itwaze |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Major | CC: | ap, karlcow, mark.lam, webkit-bug-importer, ysuzuki |
Priority: | P2 | Keywords: | BrowserCompat, InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | iPhone / iPad | ||
OS: | iOS 18 |
itwaze
Note: the issue can be reproduced on iOS 18 only.
const instance = new Intl.DurationFormat('en-US', {
style: "digital",
hoursDisplay: "auto",
})
Expected behavior:
instance.format({hours: 0, minutes: 1, seconds: 2}); // "01:02"
Current behavior:
instance.format({hours: 0, minutes: 1, seconds: 2}); // ":, 01:02"
Separators shouldn't be part of the output.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
Thank you for the report! Could you please clarify what you mean by "can be reproduced on iOS 18 only"? One can interpret this in multiple ways (e.g. that it doesn't reproduce in Safari on macOS, or doesn't reproduce on iOS 17.x, or doesn't reproduce in iOS 18.2).
Karl Dubost
Confirmed on macOS 15.2
tested on
```
":, 01:02" Safari Technology Preview 209 20621.1.6
"01:02" Firefox Nightly 135.0a1 13524.12.18
"01:02" Google Chrome Canary 133.0.6914.0 6914.0
```
Radar WebKit Bug Importer
<rdar://problem/141969050>
Karl Dubost
To note that
instance.format({hours: 1, minutes: 2, seconds: 3});
returns the same results in all browsers
"1:02:03"
Karl Dubost
In Safari:
Also `instance.formatToParts({hours: 0, minutes: 1, seconds: 2})`
```
[
{type: "literal", value: ":"},
{type: "literal", value: ", "},
{type: "integer", value: "01", unit: "minute"},
{type: "literal", value: ":"},
{type: "integer", value: "02", unit: "second"}
]
```
while `instance.formatToParts({hours: 1, minutes: 2, seconds: 3})`
```
[
{type: "integer", value: "1", unit: "hour"},
{type: "literal", value: ":"},
{type: "integer", value: "02", unit: "minute"},
{type: "literal", value: ":"},
{type: "integer", value: "03", unit: "second"}
]
```
In Firefox/Chrome
```
[
{"type": "integer", "value": "01","unit": "minute"},
{"type": "literal", "value": ":"},
{"type": "integer", "value": "02", "unit": "second"}
]
```
So there is also an issue with `formatToParts`
Karl Dubost
It's a bit of a mess.
instance.format({years: 1, days: 3, hours: 1, minutes: 2, seconds: 3});
"1 yr, 3 days, 1:02:03" (everywhere)
instance.format({years: 1, days: 3, hours: 0, minutes: 2, seconds: 3});
"1 yr, 3 days:02:03" Safari, Firefox
"1 yr, 3 days, 02:03" Chrome
instance.format({years: 0, days: 3, hours: 1, minutes: 2, seconds: 3});
"3 days, 1:02:03" (everywhere)
instance.format({years: 0, days: 0, hours: 0, minutes: 2, seconds: 3});
"02:03" Firefox, Chrome
":, 02:03" Safari
instance.format({hours: -0, minutes: -2, seconds: -3});
instance.format({hours: 0, minutes: -2, seconds: -3});
"-02:03" Firefox, Chrome
":, 02:03" Safari
Karl Dubost
const instanceFR = new Intl.DurationFormat('fr-FR', {
style: "digital",
hoursDisplay: "auto",
})
instanceFR.format({hours:0, minutes: 2, seconds: 3})
"02:03" Firefox, Chrome
": et 02:03" Safari
Sosuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/38357
EWS
Committed 288277@main (5e50f4025022): <https://commits.webkit.org/288277@main>
Reviewed commits have been landed. Closing PR #38357 and removing active labels.