1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2024 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
6 esid: sec-temporal.calendar.prototype.yearofweek
8 In the ISO 8601 week calendar, calendar week number 1 of a calendar year is
9 the week including the first Thursday of that year (based on the principle
10 that a week belongs to the same calendar year as the majority of its calendar
11 days). Because of this, some calendar days of the first calendar week of a
12 calendar year may be part of the preceding date calendar year, and some
13 calendar days of the last calendar week of a calendar year may be part of
14 the next calendar year.
20 let calendar = new Temporal.Calendar("gregory");
21 const date = { month: 1, day: 1, year: 2021, calendar};
23 assert.sameValue(calendar.yearOfWeek({...date}), 2021);
25 calendar = new Temporal.Calendar("iso8601");
26 const isodate = { month: 1, day: 1, year: 2021, calendar};
28 assert.sameValue(calendar.yearOfWeek({...isodate}), 2020);