|
| 1 | +// Copyright 2024 Google Inc. All rights reserved. |
| 2 | +// This code is governed by the BSD license found in the LICENSE file. |
| 3 | + |
| 4 | +/*--- |
| 5 | +esid: sec-formatnumerichours |
| 6 | +description: > |
| 7 | + Test to ensure that useGrouping is set to off for hours, minutes, and seconds under digital style. |
| 8 | +
|
| 9 | +info: | |
| 10 | + 1.1.9 FormatNumericHours ( durationFormat, hoursValue, signDisplayed ) |
| 11 | + ... |
| 12 | + 9. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false). |
| 13 | +
|
| 14 | + 1.1.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed ) |
| 15 | + ... |
| 16 | + 10. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false). |
| 17 | +
|
| 18 | + 1.1.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed ) |
| 19 | + ... |
| 20 | + 9. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false). |
| 21 | +
|
| 22 | +locale: [en] |
| 23 | +features: [Intl.DurationFormat] |
| 24 | +---*/ |
| 25 | + |
| 26 | +const df = new Intl.DurationFormat("en", {style: "digital"}); |
| 27 | + |
| 28 | +assert.sameValue(df.format({hours: 1234567, minutes: 20, seconds: 45}), |
| 29 | + "1234567:20:45", `format in digit set useGrouping to false`); |
| 30 | + |
| 31 | +assert.sameValue(df.format({hours: 12, minutes: 1234567, seconds: 20}), |
| 32 | + "12:1234567:20", `format in digit set useGrouping to false`); |
| 33 | + |
| 34 | +assert.sameValue(df.format({hours: 12, minutes: 34, seconds: 1234567}), |
| 35 | + "12:34:1234567", `format in digit set useGrouping to false`); |
| 36 | + |
| 37 | +assert.sameValue(df.format({hours: 12, minutes: 34, seconds: 56, milliseconds: 1234567}), |
| 38 | + "12:34:1290.567", `format in digit set useGrouping to false`); |
| 39 | + |
| 40 | +assert.sameValue(df.format({days: 1234567, hours: 3, minutes: 20, seconds: 45}), |
| 41 | + "1,234,567 days, 3:20:45", `useGrouping set to false applies to time units but not days`); |
| 42 | + |
| 43 | +assert.sameValue(df.format({days: 1234567, hours: 2345678, minutes: 3456789, seconds: 4567890}), |
| 44 | + "1,234,567 days, 2345678:3456789:4567890", `useGrouping set to false applies to time units but not days`); |
0 commit comments