Temporal: Make gregory week numbers undefined (#4467)

This commit is contained in:
Philip Chimento 2025-05-14 10:20:36 -07:00 committed by GitHub
parent 118db52dd4
commit 8fa9d38753
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 68 additions and 234 deletions

View File

@ -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);

View File

@ -9,14 +9,14 @@ description: >
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"
);

View File

@ -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);

View File

@ -9,14 +9,14 @@ description: >
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"
);

View File

@ -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);

View File

@ -9,14 +9,14 @@ description: >
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"
);

View File

@ -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);

View File

@ -9,14 +9,14 @@ description: >
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"
);

View File

@ -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");

View File

@ -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);

View File

@ -9,16 +9,14 @@ description: >
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"
);

View File

@ -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);

View File

@ -9,16 +9,14 @@ description: >
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"
);