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

Add test for useGrouping off in digital style of DurationFormat #4208

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2024 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-formatnumerichours
description: >
Test to ensure that useGrouping is set to off for hours, minutes, and seconds under digital style.

info: |
1.1.9 FormatNumericHours ( durationFormat, hoursValue, signDisplayed )
...
9. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false).

1.1.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed )
...
10. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false).

1.1.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed )
...
9. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false).

locale: [en]
features: [Intl.DurationFormat]
---*/

const df = new Intl.DurationFormat("en", {style: "digital"});

assert.sameValue(df.format({hours: 1234567, minutes: 20, seconds: 45}),
"1234567:20:45", `format in digit set useGrouping to false`);

assert.sameValue(df.format({hours: 12, minutes: 1234567, seconds: 20}),
"12:1234567:20", `format in digit set useGrouping to false`);

assert.sameValue(df.format({hours: 12, minutes: 34, seconds: 1234567}),
"12:34:1234567", `format in digit set useGrouping to false`);

assert.sameValue(df.format({hours: 12, minutes: 34, seconds: 56, milliseconds: 1234567}),
"12:34:1290.567", `format in digit set useGrouping to false`);

assert.sameValue(df.format({days: 1234567, hours: 3, minutes: 20, seconds: 45}),
"1,234,567 days, 3:20:45", `format in digit set useGrouping to false`);
FrankYFTang marked this conversation as resolved.
Show resolved Hide resolved

assert.sameValue(df.format({days: 1234567, hours: 2345678, minutes: 3456789, seconds: 4567890}),
"1,234,567 days, 2345678:3456789:4567890", `format in digit set useGrouping to false`);
FrankYFTang marked this conversation as resolved.
Show resolved Hide resolved
Loading