summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear')
-rw-r--r--js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js30
-rw-r--r--js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js25
-rw-r--r--js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js8
3 files changed, 63 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js
new file mode 100644
index 0000000000..3eeb8186ef
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js
@@ -0,0 +1,30 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2024 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.calendar.prototype.weekofyear
+description: >
+ In the ISO 8601 week calendar, calendar week number 1 of a calendar year is
+ the week including the first Thursday of that year (based on the principle
+ that a week belongs to the same calendar year as the majority of its calendar
+ days). Because of this, some calendar days of the first calendar week of a
+ calendar year may be part of the preceding date calendar year, and some
+ calendar days of the last calendar week of a calendar year may be part of
+ the next calendar year.
+features: [Temporal]
+---*/
+
+//
+
+let calendar = new Temporal.Calendar("gregory");
+const date = { month: 1, day: 1, year: 2021, calendar};
+
+assert.sameValue(calendar.weekOfYear({...date}), 1);
+
+calendar = new Temporal.Calendar("iso8601");
+const isodate = { month: 1, day: 1, year: 2021, calendar};
+
+assert.sameValue(calendar.weekOfYear({...isodate}), 53);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js
new file mode 100644
index 0000000000..9392c0c13b
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2024 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.calendar.prototype.weekofyear
+description: >
+ Temporal.Calendar.prototype.weekOfYear returns undefined for all
+ non-ISO calendars without a well-defined week numbering system.
+features: [Temporal]
+---*/
+
+// Gregorian calendar has a well defined week-numbering system.
+
+let calendar = new Temporal.Calendar("gregory");
+const date = { month: 1, day: 1, year: 2024, calendar};
+
+assert.sameValue(calendar.weekOfYear({...date}), 1);
+
+calendar = new Temporal.Calendar("hebrew");
+const nonisodate = { month: 1, day: 1, year: 2024, calendar};
+
+assert.sameValue(calendar.weekOfYear({...nonisodate}), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js
index 60f74c2518..5265d86aa2 100644
--- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js
+++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js
@@ -2022,6 +2022,9 @@ var TemporalHelpers = {
"11-18junk",
"11-18[u-ca=gregory]",
"11-18[u-ca=hebrew]",
+ "11-18[U-CA=iso8601]",
+ "11-18[u-CA=iso8601]",
+ "11-18[FOO=bar]",
];
},
@@ -2109,6 +2112,11 @@ var TemporalHelpers = {
plainYearMonthStringsInvalid() {
return [
"2020-13",
+ "1976-11[u-ca=gregory]",
+ "1976-11[u-ca=hebrew]",
+ "1976-11[U-CA=iso8601]",
+ "1976-11[u-CA=iso8601]",
+ "1976-11[FOO=bar]",
];
},