diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRangeToParts/pattern-on-calendar.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRangeToParts/pattern-on-calendar.js')
-rw-r--r-- | js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRangeToParts/pattern-on-calendar.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRangeToParts/pattern-on-calendar.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRangeToParts/pattern-on-calendar.js new file mode 100644 index 0000000000..f36730d122 --- /dev/null +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRangeToParts/pattern-on-calendar.js @@ -0,0 +1,40 @@ +// Copyright 2019 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdatetimeformat +description: > + Checks the DateTimeFormat choose different patterns based + on calendar. +includes: [testIntl.js] +features: [Intl.DateTimeFormat-formatRange] +locale: [en] +---*/ + +let calendars = allCalendars(); +let date1 = new Date(2017, 3, 12); +let date2 = new Date(); + +// serialize parts to a string by considering only the type and literal. +function serializeTypesAndLiteral(parts) { + let types = parts.map(part => { + if (part.type == "literal") { + return `${part.type}(${part.value})`; + } + return part.type; + }); + return types.join(":"); +} + +let df = new Intl.DateTimeFormat("en"); +let base = serializeTypesAndLiteral(df.formatRangeToParts(date1, date2)); + +const foundDifferentPattern = calendars.some(function(calendar) { + let cdf = new Intl.DateTimeFormat("en-u-ca-" + calendar); + return base != serializeTypesAndLiteral(cdf.formatRangeToParts(date1, date2)); +}); + +// Expect at least some calendar use different pattern. +assert.sameValue(foundDifferentPattern, true); + +reportCompare(0, 0); |