mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 00:14:35 +02:00
Temporal: Make gregory
week numbers undefined (#4467)
This commit is contained in:
parent
118db52dd4
commit
8fa9d38753
@ -1,27 +0,0 @@
|
||||
// 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 = "gregory";
|
||||
const date = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = "iso8601";
|
||||
const isodate = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(isodate.weekOfYear, 53);
|
@ -4,19 +4,19 @@
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.weekofyear
|
||||
description: >
|
||||
Temporal.PlainDate.prototype.weekOfYear returns undefined for all
|
||||
Temporal.PlainDate.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.
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDate(2024, 1, 1, "gregory").weekOfYear,
|
||||
undefined,
|
||||
"Gregorian calendar does not provide week numbers"
|
||||
);
|
||||
|
||||
let calendar = "gregory";
|
||||
const date = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = "hebrew";
|
||||
const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.weekOfYear, undefined);
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDate(2024, 1, 1, "hebrew").weekOfYear,
|
||||
undefined,
|
||||
"Hebrew calendar does not provide week numbers"
|
||||
);
|
||||
|
@ -1,27 +0,0 @@
|
||||
// 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 = "gregory";
|
||||
const date = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2021);
|
||||
|
||||
calendar = "iso8601";
|
||||
const isodate = new Temporal.PlainDate(2021, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(isodate.yearOfWeek, 2020);
|
@ -4,19 +4,19 @@
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.yearofweek
|
||||
description: >
|
||||
Temporal.PlainDate.prototype.yearOfWeek returns undefined for all
|
||||
Temporal.PlainDate.prototype.yearOfWeek 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.
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDate(2024, 1, 1, "gregory").yearOfWeek,
|
||||
undefined,
|
||||
"Gregorian calendar does not provide week numbers"
|
||||
);
|
||||
|
||||
let calendar = "gregory";
|
||||
const date = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2024);
|
||||
|
||||
calendar = "hebrew";
|
||||
const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.yearOfWeek, undefined);
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDate(2024, 1, 1, "hebrew").yearOfWeek,
|
||||
undefined,
|
||||
"Hebrew calendar does not provide week numbers"
|
||||
);
|
||||
|
@ -1,27 +0,0 @@
|
||||
// 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 = "gregory";
|
||||
const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = "iso8601";
|
||||
const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(isodate.weekOfYear, 53);
|
@ -4,19 +4,19 @@
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.weekofyear
|
||||
description: >
|
||||
Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all
|
||||
Temporal.PlainDateTime.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.
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "gregory").weekOfYear,
|
||||
undefined,
|
||||
"Gregorian calendar does not provide week numbers"
|
||||
);
|
||||
|
||||
let calendar = "gregory";
|
||||
const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = "hebrew";
|
||||
const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.weekOfYear, undefined);
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "hebrew").weekOfYear,
|
||||
undefined,
|
||||
"Hebrew calendar does not provide week numbers"
|
||||
);
|
||||
|
@ -1,27 +0,0 @@
|
||||
// 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 = "gregory";
|
||||
const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2021);
|
||||
|
||||
calendar = "iso8601";
|
||||
const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(isodate.yearOfWeek, 2020);
|
@ -4,19 +4,19 @@
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.yearofweek
|
||||
description: >
|
||||
Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all
|
||||
Temporal.PlainDateTime.prototype.yearOfWeek 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.
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "gregory").yearOfWeek,
|
||||
undefined,
|
||||
"Gregorian calendar does not provide week numbers"
|
||||
);
|
||||
|
||||
let calendar = "gregory";
|
||||
const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2024);
|
||||
|
||||
calendar = "hebrew";
|
||||
const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
|
||||
assert.sameValue(nonisodate.yearOfWeek, undefined);
|
||||
assert.sameValue(
|
||||
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "hebrew").yearOfWeek,
|
||||
undefined,
|
||||
"Hebrew calendar does not provide week numbers"
|
||||
);
|
||||
|
@ -39,8 +39,8 @@ assert.sameValue(instance.epochNanoseconds, 217178610123456789n, "epochNanosecon
|
||||
|
||||
assert.sameValue(instance.dayOfWeek, 4, "dayOfWeek");
|
||||
assert.sameValue(instance.dayOfYear, 323, "dayOfYear");
|
||||
assert.sameValue(instance.weekOfYear, 47, "weekOfYear");
|
||||
assert.sameValue(instance.yearOfWeek, 1976, "yearOfWeek");
|
||||
assert.sameValue(instance.weekOfYear, undefined, "weekOfYear");
|
||||
assert.sameValue(instance.yearOfWeek, undefined, "yearOfWeek");
|
||||
assert.sameValue(instance.daysInWeek, 7, "daysInWeek");
|
||||
assert.sameValue(instance.daysInMonth, 30, "daysInMonth");
|
||||
assert.sameValue(instance.daysInYear, 366, "daysInYear");
|
||||
|
@ -1,27 +0,0 @@
|
||||
// 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 = "gregory";
|
||||
const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = "iso8601";
|
||||
const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(isodate.weekOfYear, 53);
|
@ -4,21 +4,19 @@
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.weekofyear
|
||||
description: >
|
||||
Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all
|
||||
Temporal.ZonedDateTime.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.
|
||||
assert.sameValue(
|
||||
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "gregory").weekOfYear,
|
||||
undefined,
|
||||
"Gregorian calendar does not provide week numbers"
|
||||
);
|
||||
|
||||
let calendar = "gregory";
|
||||
|
||||
// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(date.weekOfYear, 1);
|
||||
|
||||
calendar = "hebrew";
|
||||
const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(nonisodate.weekOfYear, undefined);
|
||||
assert.sameValue(
|
||||
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "hebrew").weekOfYear,
|
||||
undefined,
|
||||
"Hebrew calendar does not provide week numbers"
|
||||
);
|
||||
|
@ -1,27 +0,0 @@
|
||||
// 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 = "gregory";
|
||||
const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2021);
|
||||
|
||||
calendar = "iso8601";
|
||||
const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(isodate.yearOfWeek, 2020);
|
@ -4,21 +4,19 @@
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.yearofweek
|
||||
description: >
|
||||
Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all
|
||||
Temporal.ZonedDateTime.prototype.yearOfWeek 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.
|
||||
assert.sameValue(
|
||||
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "gregory").yearOfWeek,
|
||||
undefined,
|
||||
"Gregorian calendar does not provide week numbers"
|
||||
);
|
||||
|
||||
let calendar = "gregory";
|
||||
|
||||
// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar);
|
||||
const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(date.yearOfWeek, 2024);
|
||||
|
||||
calendar = "hebrew";
|
||||
const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar);
|
||||
|
||||
assert.sameValue(nonisodate.yearOfWeek, undefined);
|
||||
assert.sameValue(
|
||||
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "hebrew").yearOfWeek,
|
||||
undefined,
|
||||
"Hebrew calendar does not provide week numbers"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user