Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DurationFormat: Add tests for durations with style: "digital", hoursDisplay: "auto" and zero hours #4367

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sosukesuzuki
Copy link
Contributor

@sosukesuzuki sosukesuzuki commented Dec 28, 2024

The implementation of Intl.DurationFormat in WebKit (JavaScriptCore) has passed all test262 test cases, but we discovered two incompatibilities with the specification. This Pull Request adds tests addressing those issues.

The first one is described in bug 285078. A separator is printed erroneously for an unprinted hours value:

const df = new Intl.DurationFormat('en-US', {
  style: "digital",
  hoursDisplay: "auto",
});
df.format({hours: 0, minutes: 1, seconds: 2});
// expected: "01:02"
// actual  : ":, 01:02"

The second one is described in bug 285212. A negative sign is not printed:

const df = new Intl.DurationFormat('en-US', {
  style: "digital",
  hoursDisplay: "auto",
});
df.format({ hours: 0, minutes: -2, seconds: -3 });
// expected: "-02:03"
// actual  : "02:03"

Both issues occur when style: "digital", hoursDisplay: "auto", and the hours value is 0 or absent. For that reason, they are combined into a single test file.

@sosukesuzuki sosukesuzuki requested a review from a team as a code owner December 28, 2024 10:52
// basic zero hours
[{ hours: 0, minutes: 0, seconds: 2 }, "00:02"],
[{ hours: 0, minutes: 1, seconds: 2 }, "01:02"],
[{ days: 1, hours: 0, minutes: 1, seconds: 2 }, "1 day, 01:02"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chrome prints "1 day:01:02" for this, which is correct?

@sosukesuzuki
Copy link
Contributor Author

esvu on CI fails but probably this PR isn't related

esvu ❯ version 1.2.16
JavaScriptCore ❯ Checking version...
esvu ✖ FetchError: request to https://webkitgtk.org/jsc-built-products/x86_64/release/LAST-IS failed, reason: certificate has expired
    at ClientRequest.<anonymous> (/home/circleci/test262/node_modules/node-fetch/lib/index.js:1501:11)
    at ClientRequest.emit (node:events:518:28)
    at emitErrorEvent (node:_http_client:101:11)
    at TLSSocket.socketErrorListener (node:_http_client:504:5)
    at TLSSocket.emit (node:events:518:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  type: 'system',
  errno: 'CERT_HAS_EXPIRED',
  code: 'CERT_HAS_EXPIRED'
}
esvu ✖ Some engines were not installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant