mirror of https://github.com/tc39/test262.git
Temporal: Add weekOfYear() and yearOfWeek() tests for custom calendars
This commit is contained in:
parent
ae8fe25b5a
commit
0fd1675f7e
23
test/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
23
test/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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
|
||||||
|
custom calendars where weekOfYear() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
weekOfYear() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
const customCalendarDate = { month: 1, day: 1, year: 2024, calendar};
|
||||||
|
assert.sameValue(calendar.weekOfYear({...customCalendarDate}), undefined);
|
23
test/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
23
test/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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.yearofweek
|
||||||
|
description: >
|
||||||
|
Temporal.Calendar.prototype.yearOfWeek returns undefined for all
|
||||||
|
custom calendars where yearOfWeek() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
yearOfWeek() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
const customCalendarDate = { month: 1, day: 1, year: 2024, calendar};
|
||||||
|
assert.sameValue(calendar.yearOfWeek({...customCalendarDate}), undefined);
|
23
test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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.plaindate.prototype.weekofyear
|
||||||
|
description: >
|
||||||
|
Temporal.PlainDate.prototype.weekOfYear returns undefined for all
|
||||||
|
custom calendars where weekOfYear() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
weekOfYear() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
const customCalendarDate = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||||
|
assert.sameValue(customCalendarDate.weekOfYear, undefined);
|
23
test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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.plaindate.prototype.yearofweek
|
||||||
|
description: >
|
||||||
|
Temporal.PlainDate.prototype.yearOfWeek returns undefined for all
|
||||||
|
custom calendars where yearOfWeek() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
yearOfWeek() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
const customCalendarDate = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||||
|
assert.sameValue(customCalendarDate.yearOfWeek, undefined);
|
23
test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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.plaindatetime.prototype.weekofyear
|
||||||
|
description: >
|
||||||
|
Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all
|
||||||
|
custom calendars where weekOfYear() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
weekOfYear() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
const customCalendarDate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
assert.sameValue(customCalendarDate.weekOfYear, undefined);
|
23
test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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.plaindatetime.prototype.yearofweek
|
||||||
|
description: >
|
||||||
|
Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all
|
||||||
|
custom calendars where yearOfWeek() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
yearOfWeek() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
const customCalendarDate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
assert.sameValue(customCalendarDate.yearOfWeek, undefined);
|
24
test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
24
test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// 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.zoneddatetime.prototype.weekofyear
|
||||||
|
description: >
|
||||||
|
Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all
|
||||||
|
custom calendars where weekOfYear() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
weekOfYear() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
const customCalendarDate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||||
|
assert.sameValue(customCalendarDate.weekOfYear, undefined);
|
24
test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
24
test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// 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.zoneddatetime.prototype.yearofweek
|
||||||
|
description: >
|
||||||
|
Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all
|
||||||
|
custom calendars where yearOfWeek() returns undefined.
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
|
constructor() {
|
||||||
|
super("iso8601");
|
||||||
|
}
|
||||||
|
yearOfWeek() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const calendar = new CustomCalendar();
|
||||||
|
// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
const customCalendarDate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||||
|
assert.sameValue(customCalendarDate.yearOfWeek, undefined);
|
27
test/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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);
|
27
test/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.yearofweek
|
||||||
|
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.yearOfWeek({...date}), 2021);
|
||||||
|
|
||||||
|
calendar = new Temporal.Calendar("iso8601");
|
||||||
|
const isodate = { month: 1, day: 1, year: 2021, calendar};
|
||||||
|
|
||||||
|
assert.sameValue(calendar.yearOfWeek({...isodate}), 2020);
|
27
test/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.plaindate.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 = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(date.weekOfYear, 1);
|
||||||
|
|
||||||
|
calendar = new Temporal.Calendar("iso8601");
|
||||||
|
const isodate = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(isodate.weekOfYear, 53);
|
27
test/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.plaindate.prototype.yearofweek
|
||||||
|
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 = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(date.yearOfWeek, 2021);
|
||||||
|
|
||||||
|
calendar = new Temporal.Calendar("iso8601");
|
||||||
|
const isodate = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(isodate.yearOfWeek, 2020);
|
27
test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.plaindatetime.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 = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(date.weekOfYear, 1);
|
||||||
|
|
||||||
|
calendar = new Temporal.Calendar("iso8601");
|
||||||
|
const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(isodate.weekOfYear, 53);
|
27
test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.plaindatetime.prototype.yearofweek
|
||||||
|
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 = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(date.yearOfWeek, 2021);
|
||||||
|
|
||||||
|
calendar = new Temporal.Calendar("iso8601");
|
||||||
|
const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||||
|
|
||||||
|
assert.sameValue(isodate.yearOfWeek, 2020);
|
27
test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.zoneddatetime.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 = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||||
|
|
||||||
|
assert.sameValue(date.weekOfYear, 1);
|
||||||
|
|
||||||
|
calendar = new Temporal.Calendar("iso8601");
|
||||||
|
const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||||
|
|
||||||
|
assert.sameValue(isodate.weekOfYear, 53);
|
27
test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
27
test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// 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.zoneddatetime.prototype.yearofweek
|
||||||
|
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 = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||||
|
|
||||||
|
assert.sameValue(date.yearOfWeek, 2021);
|
||||||
|
|
||||||
|
calendar = new Temporal.Calendar("iso8601");
|
||||||
|
const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||||
|
|
||||||
|
assert.sameValue(isodate.yearOfWeek, 2020);
|
Loading…
Reference in New Issue