WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
275095
[JSC] Fix behavior of `Intl.DurationFormat` for negative values
https://bugs.webkit.org/show_bug.cgi?id=275095
Summary
[JSC] Fix behavior of `Intl.DurationFormat` for negative values
Sosuke Suzuki
Reported
2024-06-03 23:53:06 PDT
The current implementation of `Intl.DurationFormat` is incorrect in two ways regarding how it handles negative values: 1. When the values of multiple units are negative, display `-` only for the largest unit. For example, the duration `{ years: -1, months: -2 }` should be formatted as `"-1 years, 2 months"`. According to the spec[1], this behavior is controlled by the `signDisplayed` variable (initially set to true). This variable is set to false once any unit is formatted. 2. Implement the DurationSign abstract operation [2] to display negative zero. For example, the duration `{ hours: 0, seconds: -1 }` should be formatted as `"-0 hours, 1 second"`. This is described in section 4.f.iii.3.b of the spec [1] as follows: > b. If value is 0 and DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]) is -1, then > i. Set value to negative-zero. The `partitionDurationFormatPattern` function [3] in the `harness/testintl.js` of test262 describes a similar process to the changes in this patch. [1]:
https://tc39.es/proposal-intl-duration-format/#sec-partitiondurationformatpattern
[2]:
https://tc39.es/proposal-intl-duration-format/#sec-durationsign
[3]:
https://github.com/tc39/test262/blob/249657722525cc8e43b1ddb91f8df0b4b011fcf6/harness/testIntl.js#L2649-L2662
Attachments
Add attachment
proposed patch, testcase, etc.
Sosuke Suzuki
Comment 1
2024-06-04 00:29:17 PDT
Pull Request:
https://github.com/WebKit/WebKit/pull/29489
Radar WebKit Bug Importer
Comment 2
2024-06-10 23:54:13 PDT
<
rdar://problem/129561747
>
EWS
Comment 3
2024-06-11 02:38:24 PDT
Committed
279902@main
(3f74bba5c41c): <
https://commits.webkit.org/279902@main
> Reviewed commits have been landed. Closing PR #29489 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug