summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DateTimeFormat
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/DateTimeFormat')
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js2
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js2
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js2
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js2
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js2
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js38
-rw-r--r--js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js45
7 files changed, 73 insertions, 20 deletions
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js
index 13b8f374b3..0e6761b04a 100644
--- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js
+++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js
@@ -5,7 +5,7 @@
esid: sec-createdatetimeformat
description: Checks basic handling of dayPeriod, long format.
features: [Intl.DateTimeFormat-dayPeriod]
-locale: [en-US]
+locale: [en]
---*/
const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0);
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js
index 4d26a5131d..986ff1f157 100644
--- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js
+++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js
@@ -5,7 +5,7 @@
esid: sec-createdatetimeformat
description: Checks basic handling of dayPeriod, narrow format.
features: [Intl.DateTimeFormat-dayPeriod]
-locale: [en-US]
+locale: [en]
---*/
const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0);
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js
index f7b410f24d..dec193c396 100644
--- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js
+++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js
@@ -5,7 +5,7 @@
esid: sec-initializedatetimeformat
description: Checks basic handling of dayPeriod, short format.
features: [Intl.DateTimeFormat-dayPeriod]
-locale: [en-US]
+locale: [en]
---*/
const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0);
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js
index 25af5ada6d..49218a3b39 100644
--- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js
+++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js
@@ -5,7 +5,7 @@
esid: sec-createdatetimeformat
description: Checks basic handling of fractionalSecondDigits.
features: [Intl.DateTimeFormat-fractionalSecondDigits]
-locale: [en-US]
+locale: [en]
---*/
const d1 = new Date(2019, 7, 10, 1, 2, 3, 234);
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js
index 543dfb2274..046084493c 100644
--- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js
+++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js
@@ -5,7 +5,7 @@
esid: sec-createdatetimeformat
description: Checks basic handling of fractionalSecondDigits.
features: [Intl.DateTimeFormat-fractionalSecondDigits]
-locale: [en-US]
+locale: [en]
---*/
const d1 = new Date(2019, 7, 10, 1, 2, 3, 234);
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js
index 9063e045a6..c2cccd826c 100644
--- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js
+++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js
@@ -21,27 +21,35 @@ info: |
c. If hc is null, set hc to dataLocaleData.[[hourCycle]].
27. Set dateTimeFormat.[[HourCycle]] to hc.
-locale: [en, fr, it, ja, zh, ko, ar, hi, en-u-hc-h24]
+locale: [en, fr, it, ja, zh, ko, ar, hi]
---*/
-let locales = ["en", "fr", "it", "ja", "ja-u-hc-h11", "zh", "ko", "ar", "hi", "en-u-hc-h24"];
+let locales = ["en", "fr", "it", "ja", "zh", "ko", "ar", "hi"];
-locales.forEach(function(locale) {
- let hcDefault = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hourCycle;
- if (hcDefault === "h11" || hcDefault === "h12") {
- assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true }).resolvedOptions().hourCycle, hcDefault);
+for (let locale of locales) {
+ let hcDefault = new Intl.DateTimeFormat(locale, {hour: "numeric"}).resolvedOptions().hourCycle;
+ assert(
+ hcDefault === "h11" || hcDefault === "h12" || hcDefault === "h23" || hcDefault === "h24",
+ "hcDefault is one of [h11, h12, h23, h24]"
+ );
- // no locale has "h24" as a default. see https://github.com/tc39/ecma402/pull/758#issue-1622377292
- assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false }).resolvedOptions().hourCycle, "h23");
- }
+ let hour12 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle;
+ assert(hour12 === "h11" || hour12 === "h12", "hour12 is one of [h11, h12]");
+
+ let hour24 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle;
+ assert(hour24 === "h23" || hour24 === "h24", "hour24 is one of [h23, h24]");
- // however, "h24" can be set via locale extension.
- if (hcDefault === "h23" || hcDefault === "h24") {
- assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false }).resolvedOptions().hourCycle, hcDefault);
+ if (hcDefault === "h11" || hcDefault === "h12") {
+ assert.sameValue(hour12, hcDefault, "hour12 matches hcDefault");
+ } else {
+ assert.sameValue(hour24, hcDefault, "hour24 matches hcDefault");
}
- let hcHour12 = new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true }).resolvedOptions().hourCycle;
- assert(hcHour12 === "h11" || hcHour12 === "h12", "Expected `hourCycle`: " + hcHour12 + " to be in [\"h11\", \"h12\"]");
-});
+ // 24-hour clock uses the "h23" format in all locales.
+ assert.sameValue(hour24, "h23");
+
+ // 12-hour clock uses the "h12" format in all locales except "ja".
+ assert.sameValue(hour12, locale === "ja" ? "h11" : "h12");
+}
reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js b/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js
new file mode 100644
index 0000000000..d99cf18df4
--- /dev/null
+++ b/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2024 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-initializedatetimeformat
+description: Only IANA time zone identifiers are allowed.
+---*/
+
+// List of non-IANA link names, copied from:
+// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones
+const invalidTimeZones = [
+ "ACT",
+ "AET",
+ "AGT",
+ "ART",
+ "AST",
+ "BET",
+ "BST",
+ "CAT",
+ "CNT",
+ "CST",
+ "CTT",
+ "EAT",
+ "ECT",
+ "IET",
+ "IST",
+ "JST",
+ "MIT",
+ "NET",
+ "NST",
+ "PLT",
+ "PNT",
+ "PRT",
+ "PST",
+ "SST",
+ "VST",
+];
+
+for (let timeZone of invalidTimeZones) {
+ assert.throws(RangeError, () => {
+ new Intl.DateTimeFormat(undefined, {timeZone});
+ }, "Time zone: " + timeZone);
+}
+
+reportCompare(0, 0);