From 0cbf08900e5bd26692daa5ca017b3331de10e689 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 22 Aug 2024 14:54:20 -0700 Subject: [PATCH 1/2] Add test for useGrouping off in digital style of DurationFormat Fix #4190 --- .../format/style-digital-largenumber-en.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js diff --git a/test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js b/test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js new file mode 100644 index 00000000000..773210176eb --- /dev/null +++ b/test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js @@ -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`); + +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`); From 56e461fe5c57f1dfcabe0ad2244d831b84f5b553 Mon Sep 17 00:00:00 2001 From: Frank Yung-Fong Tang Date: Fri, 23 Aug 2024 11:55:42 -0700 Subject: [PATCH 2/2] change based on review feedback --- .../prototype/format/style-digital-largenumber-en.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js b/test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js index 773210176eb..4130cc9a73c 100644 --- a/test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js +++ b/test/intl402/DurationFormat/prototype/format/style-digital-largenumber-en.js @@ -38,7 +38,7 @@ assert.sameValue(df.format({hours: 12, minutes: 34, seconds: 56, milliseconds: 1 "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`); + "1,234,567 days, 3:20:45", `useGrouping set to false applies to time units but not days`); 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`); + "1,234,567 days, 2345678:3456789:4567890", `useGrouping set to false applies to time units but not days`);