mirror of https://github.com/tc39/test262.git
Temporal: Don't use getISOFields() in other tests
Previously getISOFields() was used to get the exact value of the [[Calendar]] and [[TimeZone]] internal slots, as well as to get the reference ISO year for PlainMonthDay and reference ISO day for PlainYearMonth. Use calendarId and timeZoneId for the former and toString() for the latter.
This commit is contained in:
parent
7e4de57437
commit
efc7424844
|
@ -178,8 +178,8 @@ var TemporalHelpers = {
|
|||
assert(actual instanceof Temporal.PlainDateTime, `${prefix}instanceof`);
|
||||
assert(actual.equals(expected), `${prefix}equals method`);
|
||||
assert.sameValue(
|
||||
actual.getISOFields().calendar,
|
||||
expected.getISOFields().calendar,
|
||||
actual.calendarId,
|
||||
expected.calendarId,
|
||||
`${prefix}calendar same value:`
|
||||
);
|
||||
},
|
||||
|
@ -197,7 +197,8 @@ var TemporalHelpers = {
|
|||
assert(monthDay instanceof Temporal.PlainMonthDay, `${prefix}instanceof`);
|
||||
assert.sameValue(monthDay.monthCode, monthCode, `${prefix}monthCode result:`);
|
||||
assert.sameValue(monthDay.day, day, `${prefix}day result:`);
|
||||
assert.sameValue(monthDay.getISOFields().isoYear, referenceISOYear, `${prefix}referenceISOYear result:`);
|
||||
const isoYear = Number(monthDay.toString({ calendarName: "always" }).split("-")[0]);
|
||||
assert.sameValue(isoYear, referenceISOYear, `${prefix}referenceISOYear result:`);
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -246,7 +247,8 @@ var TemporalHelpers = {
|
|||
assert.sameValue(yearMonth.year, year, `${prefix}year result:`);
|
||||
assert.sameValue(yearMonth.month, month, `${prefix}month result:`);
|
||||
assert.sameValue(yearMonth.monthCode, monthCode, `${prefix}monthCode result:`);
|
||||
assert.sameValue(yearMonth.getISOFields().isoDay, referenceISODay, `${prefix}referenceISODay result:`);
|
||||
const isoDay = Number(yearMonth.toString({ calendarName: "always" }).slice(1).split('-')[2].slice(0, 2));
|
||||
assert.sameValue(isoDay, referenceISODay, `${prefix}referenceISODay result:`);
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -263,8 +265,8 @@ var TemporalHelpers = {
|
|||
assert(actual.equals(expected), `${prefix}equals method`);
|
||||
assert.sameValue(actual.timeZone, expected.timeZone, `${prefix}time zone same value:`);
|
||||
assert.sameValue(
|
||||
actual.getISOFields().calendar,
|
||||
expected.getISOFields().calendar,
|
||||
actual.calendarId,
|
||||
expected.calendarId,
|
||||
`${prefix}calendar same value:`
|
||||
);
|
||||
},
|
||||
|
|
|
@ -10,4 +10,4 @@ features: [Temporal]
|
|||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
const result = instance.toZonedDateTimeISO("UTC");
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
/*---
|
||||
esid: sec-temporal.instant.prototype.tozoneddatetimeiso
|
||||
description: Time zone IDs are valid input for a time zone
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
|
@ -12,5 +11,5 @@ const instance = new Temporal.Instant(0n);
|
|||
|
||||
["UTC", "+01:30"].forEach((timeZone) => {
|
||||
const result = instance.toZonedDateTimeISO(timeZone);
|
||||
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
});
|
||||
|
|
|
@ -9,4 +9,4 @@ features: [Temporal]
|
|||
|
||||
const d = Temporal.Now.plainDateISO();
|
||||
assert(d instanceof Temporal.PlainDate);
|
||||
assert.sameValue(d.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(d.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
|
|
|
@ -8,4 +8,4 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const result = Temporal.Now.plainDateTimeISO();
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
|
|
|
@ -8,7 +8,6 @@ features: [Temporal]
|
|||
---*/
|
||||
|
||||
const zdt = Temporal.Now.zonedDateTimeISO();
|
||||
const tz = Temporal.Now.timeZoneId();
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert.sameValue(zdt.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(zdt.getISOFields().timeZone, tz, "time zone slot should store a string");
|
||||
assert.sameValue(zdt.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
assert.sameValue(zdt.timeZoneId, Temporal.Now.timeZoneId(), "time zone string should be the same as from Now");
|
||||
|
|
|
@ -4,14 +4,13 @@
|
|||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Functions when time zone argument is omitted
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const systemTimeZone = Temporal.Now.timeZoneId();
|
||||
|
||||
const resultExplicit = Temporal.Now.zonedDateTimeISO(undefined);
|
||||
assert.sameValue(resultExplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string");
|
||||
assert.sameValue(resultExplicit.timeZoneId, systemTimeZone, "time zone string should be the system time zone");
|
||||
|
||||
const resultImplicit = Temporal.Now.zonedDateTimeISO();
|
||||
assert.sameValue(resultImplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string");
|
||||
assert.sameValue(resultImplicit.timeZoneId, systemTimeZone, "time zone string should be the system time zone");
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Time zone IDs are valid input for a time zone
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
["UTC", "+01:30"].forEach((timeZone) => {
|
||||
const result = Temporal.Now.zonedDateTimeISO(timeZone);
|
||||
assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`);
|
||||
assert.sameValue(result.timeZoneId, timeZone, `Time zone created from string "${timeZone}"`);
|
||||
});
|
||||
|
|
|
@ -10,4 +10,4 @@ features: [Temporal]
|
|||
|
||||
const plainDate = new Temporal.PlainDate(2020, 12, 24, "iso8601");
|
||||
TemporalHelpers.assertPlainDate(plainDate, 2020, 12, "M12", 24, "with string");
|
||||
assert.sameValue(plainDate.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(plainDate.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -10,4 +10,4 @@ features: [Temporal]
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = new Temporal.PlainDate(2000, 5, 2, arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -10,7 +10,7 @@ features: [Temporal]
|
|||
const args = [2020, 12, 24];
|
||||
|
||||
const dateExplicit = new Temporal.PlainDate(...args, undefined);
|
||||
assert.sameValue(dateExplicit.getISOFields().calendar, "iso8601", "calendar slot should store string");
|
||||
assert.sameValue(dateExplicit.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
||||
const dateImplicit = new Temporal.PlainDate(...args);
|
||||
assert.sameValue(dateImplicit.getISOFields().calendar, "iso8601", "calendar slot should store string");
|
||||
assert.sameValue(dateImplicit.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDate(
|
|||
"PlainDate is copied"
|
||||
);
|
||||
|
||||
assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied");
|
||||
assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied");
|
||||
|
||||
assert.notSameValue(
|
||||
result,
|
||||
|
|
|
@ -21,5 +21,5 @@ for (const calendar of [
|
|||
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||
const result = Temporal.PlainDate.from(arg);
|
||||
TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ const calendar = "iso8601";
|
|||
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||
const result = Temporal.PlainDate.from(arg);
|
||||
TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -11,4 +11,4 @@ features: [Temporal]
|
|||
const calendar = "iso8601";
|
||||
const plainDate = Temporal.PlainDate.from({ year: 1976, month: 11, day: 18, calendar });
|
||||
TemporalHelpers.assertPlainDate(plainDate, 1976, 11, "M11", 18);
|
||||
assert.sameValue(plainDate.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(plainDate.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -19,7 +19,7 @@ TemporalHelpers.assertPlainDate(
|
|||
);
|
||||
|
||||
assert.sameValue(
|
||||
result.getISOFields().calendar,
|
||||
result.calendarId,
|
||||
calendar,
|
||||
"Calendar is copied"
|
||||
);
|
||||
|
|
|
@ -11,4 +11,4 @@ features: [Temporal]
|
|||
const pd = new Temporal.PlainDate(1970, 12, 24, "iso8601");
|
||||
const pmd = pd.toPlainMonthDay();
|
||||
TemporalHelpers.assertPlainMonthDay(pmd, "M12", 24);
|
||||
assert.sameValue(pmd.getISOFields().calendar, "iso8601");
|
||||
assert.sameValue(pmd.calendarId, "iso8601");
|
||||
|
|
|
@ -11,4 +11,4 @@ features: [Temporal]
|
|||
const pd = new Temporal.PlainDate(1970, 12, 24, "iso8601");
|
||||
const pym = pd.toPlainYearMonth();
|
||||
TemporalHelpers.assertPlainYearMonth(pym, 1970, 12, "M12");
|
||||
assert.sameValue(pym.getISOFields().calendar, "iso8601");
|
||||
assert.sameValue(pym.calendarId, "iso8601");
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.tozoneddatetime
|
||||
description: Time zone IDs are valid input for a time zone
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
|
@ -12,5 +11,5 @@ const instance = new Temporal.PlainDate(2000, 5, 2);
|
|||
|
||||
["UTC", "+01:30"].forEach((timeZone) => {
|
||||
const result = instance.toZonedDateTime(timeZone);
|
||||
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
});
|
||||
|
|
|
@ -14,4 +14,4 @@ const calendar = "iso8601";
|
|||
const stringResult = plainDate.withCalendar("iso8601");
|
||||
assert.notSameValue(stringResult, plainDate, "string: new object");
|
||||
TemporalHelpers.assertPlainDate(stringResult, 1976, 11, "M11", 18, "string");
|
||||
assert.sameValue(stringResult.getISOFields().calendar, "iso8601", "string: calendar slot stores a string");
|
||||
assert.sameValue(stringResult.calendarId, "iso8601", "string: calendar is iso8601");
|
||||
|
|
|
@ -20,5 +20,5 @@ for (const arg of [
|
|||
"2020-01[u-ca=iso8601]",
|
||||
]) {
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
}
|
||||
|
|
|
@ -12,4 +12,4 @@ const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601");
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -24,8 +24,6 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
|||
const actual = [];
|
||||
const expected = [];
|
||||
|
||||
const calendar = arg.getISOFields().calendar;
|
||||
|
||||
Object.defineProperty(arg, "calendar", {
|
||||
get() {
|
||||
actual.push("get calendar");
|
||||
|
@ -35,7 +33,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
|||
|
||||
const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601");
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
|
|
@ -15,6 +15,6 @@ TemporalHelpers.checkSubclassingIgnored(
|
|||
["iso8601"],
|
||||
(result) => {
|
||||
TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar result");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar result");
|
||||
},
|
||||
);
|
||||
|
|
|
@ -10,4 +10,4 @@ features: [Temporal]
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -16,7 +16,7 @@ TemporalHelpers.assertPlainDateTime(datetime,
|
|||
);
|
||||
|
||||
assert.sameValue(
|
||||
datetime.getISOFields().calendar,
|
||||
datetime.calendarId,
|
||||
"iso8601",
|
||||
"calendar supplied in constructor can be extracted and is unchanged"
|
||||
);
|
||||
|
|
|
@ -17,5 +17,5 @@ features: [Temporal]
|
|||
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => {
|
||||
const result = Temporal.PlainDateTime.from(date);
|
||||
TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed");
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar result");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar result");
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDateTime(
|
|||
"PlainDateTime is copied"
|
||||
);
|
||||
|
||||
assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied");
|
||||
assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied");
|
||||
|
||||
assert.notSameValue(
|
||||
result,
|
||||
|
|
|
@ -21,5 +21,5 @@ for (const calendar of [
|
|||
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||
const result = Temporal.PlainDateTime.from(arg);
|
||||
TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ const calendar = "iso8601";
|
|||
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||
const result = Temporal.PlainDateTime.from(arg);
|
||||
TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -22,5 +22,5 @@ features: [Temporal]
|
|||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||
const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar");
|
||||
});
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.tozoneddatetime
|
||||
description: Time zone IDs are valid input for a time zone
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
|
@ -12,5 +11,5 @@ const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
|||
|
||||
["UTC", "+01:30"].forEach((timeZone) => {
|
||||
const result = instance.toZonedDateTime(timeZone);
|
||||
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
});
|
||||
|
|
|
@ -19,4 +19,4 @@ TemporalHelpers.assertPlainDateTime(
|
|||
"works"
|
||||
);
|
||||
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "underlying calendar is unchanged");
|
||||
assert.sameValue(result.calendarId, calendar, "underlying calendar is unchanged");
|
||||
|
|
|
@ -20,5 +20,5 @@ for (const arg of [
|
|||
"2020-01[u-ca=iso8601]",
|
||||
]) {
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
}
|
||||
|
|
|
@ -12,4 +12,4 @@ const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456,
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -24,8 +24,6 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
|||
const actual = [];
|
||||
const expected = [];
|
||||
|
||||
const calendar = arg.getISOFields().calendar;
|
||||
|
||||
Object.defineProperty(arg, "calendar", {
|
||||
get() {
|
||||
actual.push("get calendar");
|
||||
|
@ -35,7 +33,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
|||
|
||||
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601");
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
|
|
@ -10,4 +10,4 @@ features: [Temporal]
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = new Temporal.PlainMonthDay(12, 15, arg, 1972);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -18,7 +18,7 @@ TemporalHelpers.assertPlainMonthDay(
|
|||
/* isoYear = */ 2000
|
||||
);
|
||||
|
||||
assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied");
|
||||
assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied");
|
||||
|
||||
assert.notSameValue(
|
||||
result,
|
||||
|
|
|
@ -21,5 +21,5 @@ for (const calendar of [
|
|||
const arg = { monthCode: "M11", day: 18, calendar };
|
||||
const result = Temporal.PlainMonthDay.from(arg);
|
||||
TemporalHelpers.assertPlainMonthDay(result, "M11", 18, `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ const calendar = "iso8601";
|
|||
const arg = { monthCode: "M11", day: 18, calendar };
|
||||
const result = Temporal.PlainMonthDay.from(arg);
|
||||
TemporalHelpers.assertPlainMonthDay(result, "M11", 18, `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -22,5 +22,5 @@ features: [Temporal]
|
|||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||
const result = Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar: temporalObject });
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar");
|
||||
});
|
||||
|
|
|
@ -10,7 +10,9 @@ features: [Temporal]
|
|||
const args = [5, 2, "iso8601"];
|
||||
|
||||
const dateExplicit = new Temporal.PlainMonthDay(...args, undefined);
|
||||
assert.sameValue(dateExplicit.getISOFields().isoYear, 1972, "default referenceISOYear is 1972");
|
||||
const isoYearExplicit = Number(dateExplicit.toString({ calendarName: "always" }).slice(0, 4));
|
||||
assert.sameValue(isoYearExplicit, 1972, "default referenceISOYear is 1972");
|
||||
|
||||
const dateImplicit = new Temporal.PlainMonthDay(...args);
|
||||
assert.sameValue(dateImplicit.getISOFields().isoYear, 1972, "default referenceISOYear is 1972");
|
||||
const isoYearImplicit = Number(dateImplicit.toString({ calendarName: "always" }).slice(0, 4));
|
||||
assert.sameValue(isoYearImplicit, 1972, "default referenceISOYear is 1972");
|
||||
|
|
|
@ -10,4 +10,4 @@ features: [Temporal]
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = new Temporal.PlainYearMonth(2000, 5, arg, 1);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -11,8 +11,5 @@ features: [Temporal]
|
|||
const plainDate = Temporal.PlainDate.from("1976-11-18");
|
||||
const plainYearMonth = Temporal.PlainYearMonth.from(plainDate);
|
||||
TemporalHelpers.assertPlainYearMonth(plainYearMonth, 1976, 11, "M11");
|
||||
const fields = plainYearMonth.getISOFields();
|
||||
assert.sameValue(fields.calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(fields.isoDay, 1, "isoDay");
|
||||
assert.sameValue(fields.isoMonth, 11, "isoMonth");
|
||||
assert.sameValue(fields.isoYear, 1976, "isoYear");
|
||||
assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "1976-11-01[u-ca=iso8601]", "iso reference date");
|
||||
|
|
|
@ -18,7 +18,7 @@ TemporalHelpers.assertPlainYearMonth(
|
|||
/* era = */ undefined, /* eraYear = */ undefined, /* isoDay = */ 7
|
||||
);
|
||||
|
||||
assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied");
|
||||
assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied");
|
||||
|
||||
assert.notSameValue(
|
||||
result,
|
||||
|
|
|
@ -21,5 +21,5 @@ for (const calendar of [
|
|||
const arg = { year: 2019, monthCode: "M06", calendar };
|
||||
const result = Temporal.PlainYearMonth.from(arg);
|
||||
TemporalHelpers.assertPlainYearMonth(result, 2019, 6, "M06", `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ const calendar = "iso8601";
|
|||
const arg = { year: 2019, monthCode: "M06", calendar };
|
||||
const result = Temporal.PlainYearMonth.from(arg);
|
||||
TemporalHelpers.assertPlainYearMonth(result, 2019, 6, "M06", `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -11,20 +11,13 @@ features: [Temporal]
|
|||
for (const input of TemporalHelpers.ISO.plainYearMonthStringsValid()) {
|
||||
const plainYearMonth = Temporal.PlainYearMonth.from(input);
|
||||
TemporalHelpers.assertPlainYearMonth(plainYearMonth, 1976, 11, "M11");
|
||||
const fields = plainYearMonth.getISOFields();
|
||||
assert.sameValue(fields.calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(fields.isoDay, 1, "isoDay");
|
||||
assert.sameValue(fields.isoMonth, 11, "isoMonth");
|
||||
assert.sameValue(fields.isoYear, 1976, "isoYear");
|
||||
assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "1976-11-01[u-ca=iso8601]", "iso reference date");
|
||||
}
|
||||
|
||||
for (const input of TemporalHelpers.ISO.plainYearMonthStringsValidNegativeYear()) {
|
||||
const plainYearMonth = Temporal.PlainYearMonth.from(input);
|
||||
TemporalHelpers.assertPlainYearMonth(plainYearMonth, -9999, 11, "M11");
|
||||
const fields = plainYearMonth.getISOFields();
|
||||
assert.sameValue(fields.calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(fields.isoDay, 1, "isoDay");
|
||||
assert.sameValue(fields.isoMonth, 11, "isoMonth");
|
||||
assert.sameValue(fields.isoYear, -9999, "isoYear");
|
||||
assert.sameValue(plainYearMonth.toString(), "-009999-11");
|
||||
assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "-009999-11-01[u-ca=iso8601]", "iso reference date");
|
||||
}
|
||||
|
|
|
@ -22,5 +22,5 @@ features: [Temporal]
|
|||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||
const result = Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar: temporalObject });
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar");
|
||||
});
|
||||
|
|
|
@ -19,5 +19,5 @@ TemporalHelpers.assertPlainYearMonth(ym.with({ month: 1, years: 2020 }), 2019, 1
|
|||
|
||||
const withDay = ym.with({ year: 2019, get day() { throw new Test262Error("should not read the day property") } });
|
||||
TemporalHelpers.assertPlainYearMonth(withDay, 2019, 10, "M10", "day property");
|
||||
assert.sameValue(withDay.getISOFields().isoDay, 1);
|
||||
|
||||
const isoDay = Number(withDay.toString({ calendarName: "always" }).split("-")[2].slice(0, 2));
|
||||
assert.sameValue(isoDay, 1);
|
||||
|
|
|
@ -10,7 +10,9 @@ features: [Temporal]
|
|||
const args = [2000, 5];
|
||||
|
||||
const dateExplicit = new Temporal.PlainYearMonth(...args, undefined);
|
||||
assert.sameValue(dateExplicit.getISOFields().isoDay, 1, "default referenceISODay is 1");
|
||||
const isoDayExplicit = Number(dateExplicit.toString({ calendarName: "always" }).split("-")[2].slice(0, 2));
|
||||
assert.sameValue(isoDayExplicit, 1, "default referenceISODay is 1");
|
||||
|
||||
const dateImplicit = new Temporal.PlainYearMonth(...args);
|
||||
assert.sameValue(dateImplicit.getISOFields().isoDay, 1, "default referenceISODay is 1");
|
||||
const isoDayImplicit = Number(dateImplicit.toString({ calendarName: "always" }).split("-")[2].slice(0, 2));
|
||||
assert.sameValue(isoDayImplicit, 1, "default referenceISODay is 1");
|
||||
|
|
|
@ -10,4 +10,4 @@ features: [Temporal]
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = new Temporal.ZonedDateTime(0n, "UTC", arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -10,7 +10,7 @@ features: [BigInt, Temporal]
|
|||
const args = [957270896987654321n, "UTC"];
|
||||
|
||||
const explicit = new Temporal.ZonedDateTime(...args, undefined);
|
||||
assert.sameValue(explicit.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(explicit.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
|
||||
const implicit = new Temporal.ZonedDateTime(...args);
|
||||
assert.sameValue(implicit.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.sameValue(implicit.calendarId, "iso8601", "calendar string should be iso8601");
|
||||
|
|
|
@ -21,5 +21,5 @@ for (const calendar of [
|
|||
const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar };
|
||||
const result = Temporal.ZonedDateTime.from(arg);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ const timeZone = "UTC";
|
|||
const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar };
|
||||
const result = Temporal.ZonedDateTime.from(arg);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${calendar}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601");
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
/*---
|
||||
esid: sec-temporal.zoneddatetime.from
|
||||
description: Time zone IDs are valid input for a time zone
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
["UTC", "+01:30"].forEach((timeZone) => {
|
||||
const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone });
|
||||
assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`);
|
||||
assert.sameValue(result.timeZoneId, timeZone, `Time zone created from string "${timeZone}"`);
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ const result = Temporal.ZonedDateTime.from(orig);
|
|||
|
||||
assert.sameValue(result.epochNanoseconds, 946684800_000_000_010n, "ZonedDateTime is copied");
|
||||
assert.sameValue(result.timeZone, orig.timeZone, "time zone is the same");
|
||||
assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "calendar is the same");
|
||||
assert.sameValue(result.calendarId, orig.calendarId, "calendar is the same");
|
||||
|
||||
assert.notSameValue(
|
||||
result,
|
||||
|
|
|
@ -22,5 +22,5 @@ features: [Temporal]
|
|||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||
const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: temporalObject });
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar");
|
||||
});
|
||||
|
|
|
@ -20,5 +20,5 @@ for (const arg of [
|
|||
"2020-01[u-ca=iso8601]",
|
||||
]) {
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
}
|
||||
|
|
|
@ -12,4 +12,4 @@ const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "
|
|||
const arg = "iso8601";
|
||||
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
|
|
@ -24,8 +24,6 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
|||
const actual = [];
|
||||
const expected = [];
|
||||
|
||||
const calendar = arg.getISOFields().calendar;
|
||||
|
||||
Object.defineProperty(arg, "calendar", {
|
||||
get() {
|
||||
actual.push("get calendar");
|
||||
|
@ -35,7 +33,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
|||
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
|
|
@ -24,6 +24,6 @@ TemporalHelpers.checkSubclassingIgnored(
|
|||
assert.sameValue(result.millisecond, 0, "millisecond result");
|
||||
assert.sameValue(result.microsecond, 0, "microsecond result");
|
||||
assert.sameValue(result.nanosecond, 10, "nanosecond result");
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar result");
|
||||
assert.sameValue(result.calendarId, "iso8601", "calendar result");
|
||||
},
|
||||
);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.withtimezone
|
||||
description: Time zone IDs are valid input for a time zone
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
|
@ -12,5 +11,5 @@ const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
|||
|
||||
["UTC", "+01:30"].forEach((timeZone) => {
|
||||
const result = instance.withTimeZone(timeZone);
|
||||
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
});
|
||||
|
|
|
@ -9,5 +9,5 @@ features: [Temporal]
|
|||
|
||||
["UTC", "+01:30"].forEach((timeZone) => {
|
||||
const result = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`);
|
||||
assert.sameValue(result.timeZoneId, timeZone, `time zone ID should be "${timeZone}"`);
|
||||
});
|
||||
|
|
|
@ -9,7 +9,5 @@ features: [Temporal]
|
|||
|
||||
const zdt = Temporal.Now.zonedDateTimeISO("America/Los_Angeles");
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string");
|
||||
assert.sameValue(zdt.calendarId, "iso8601");
|
||||
assert.sameValue(typeof zdt.getISOFields().timeZone, "string", "time zone slot should store a string");
|
||||
assert.sameValue(zdt.timeZoneId, "America/Los_Angeles");
|
||||
|
|
|
@ -17,11 +17,7 @@ TemporalHelpers.assertPlainDateTime(
|
|||
"'iso8601' is a recognizable calendar"
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
result.getISOFields().calendar,
|
||||
"iso8601",
|
||||
"underlying calendar has changed and calendar slot stores a string"
|
||||
);
|
||||
assert.sameValue(result.calendarId, "iso8601", "underlying calendar has changed");
|
||||
|
||||
assert.throws(
|
||||
RangeError,
|
||||
|
|
|
@ -68,5 +68,4 @@ TemporalHelpers.assertPlainMonthDay(
|
|||
"reference date should be the later one, if two options exist in ISO year 1972",
|
||||
1972
|
||||
);
|
||||
assert.sameValue(result7.getISOFields().isoMonth, 12, "reference date should be 1972-12-31");
|
||||
assert.sameValue(result7.getISOFields().isoDay, 31, "reference date should be 1972-12-31");
|
||||
assert.sameValue(result7.toString(), "1972-12-31[u-ca=hebrew]", "reference date");
|
||||
|
|
|
@ -78,7 +78,6 @@ for (const [monthCode, relatedYear, month, referenceISODay, isoYear = relatedYea
|
|||
`Date of sample Chinese intercalary month ${monthCode}`,
|
||||
/* era = */ undefined, /* era year = */ undefined, referenceISODay
|
||||
);
|
||||
const isoFields = result.getISOFields();
|
||||
assert.sameValue(isoFields.isoYear, isoYear, `${year}-${monthCode} starts in ISO year ${isoYear}`);
|
||||
assert.sameValue(isoFields.isoMonth, isoMonth, `${year}-${monthCode} starts in ISO month ${isoMonth}`);
|
||||
const isoYearMonth = result.toString().slice(0, 7);
|
||||
assert.sameValue(isoYearMonth, `${isoYear}-${String(isoMonth).padStart(2, '0')}`, `${year}-${monthCode} starts in ISO month ${isoYear}-${isoMonth}`);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,8 @@ TemporalHelpers.assertPlainYearMonth(
|
|||
"reference day is the first of the calendar month even if day is given",
|
||||
/* era = */ undefined, /* era year = */ undefined, /* reference day = */ 5
|
||||
);
|
||||
const isoFields = result4.getISOFields();
|
||||
assert.sameValue(isoFields.isoYear, 2021, "Tevet 5782 begins in ISO year 2021");
|
||||
assert.sameValue(isoFields.isoMonth, 12, "Tevet 5782 begins in ISO month 12");
|
||||
const isoYearMonth = result4.toString().slice(0, 7);
|
||||
assert.sameValue(isoYearMonth, "2021-12", "Tevet 5782 begins in ISO 2021-12");
|
||||
|
||||
const result5 = Temporal.PlainYearMonth.from({ year: 5783, monthCode: "M05L", calendar: "hebrew" }, { overflow: "constrain" });
|
||||
TemporalHelpers.assertPlainYearMonth(
|
||||
|
|
|
@ -15,53 +15,42 @@ const tests = [
|
|||
inLeapYear: false,
|
||||
daysInYear: 354,
|
||||
daysInMonth12: 29,
|
||||
isoYear: 2023,
|
||||
isoMonth: 7,
|
||||
isoDay: 18
|
||||
isoDate: "2023-07-18",
|
||||
},
|
||||
{
|
||||
calendar: "islamic-umalqura",
|
||||
inLeapYear: false,
|
||||
daysInYear: 354,
|
||||
daysInMonth12: 30,
|
||||
isoYear: 2023,
|
||||
isoMonth: 7,
|
||||
isoDay: 19
|
||||
isoDate: "2023-07-19",
|
||||
},
|
||||
{
|
||||
calendar: "islamic-civil",
|
||||
inLeapYear: true,
|
||||
daysInYear: 355,
|
||||
daysInMonth12: 30,
|
||||
isoYear: 2023,
|
||||
isoMonth: 7,
|
||||
isoDay: 19
|
||||
isoDate: "2023-07-19",
|
||||
},
|
||||
{
|
||||
calendar: "islamic-rgsa",
|
||||
inLeapYear: false,
|
||||
daysInYear: 354,
|
||||
daysInMonth12: 29,
|
||||
isoYear: 2023,
|
||||
isoMonth: 7,
|
||||
isoDay: 18
|
||||
isoDate: "2023-07-18",
|
||||
},
|
||||
{
|
||||
calendar: "islamic-tbla",
|
||||
inLeapYear: true,
|
||||
daysInYear: 355,
|
||||
daysInMonth12: 30,
|
||||
isoYear: 2023,
|
||||
isoMonth: 7,
|
||||
isoDay: 18
|
||||
isoDate: "2023-07-18",
|
||||
}
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
const { calendar, inLeapYear, daysInYear, daysInMonth12, isoYear, isoMonth, isoDay } = test;
|
||||
const { calendar, inLeapYear, daysInYear, daysInMonth12, isoDate } = test;
|
||||
const year = 1445;
|
||||
const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar });
|
||||
const isoFields = date.getISOFields();
|
||||
assert.sameValue(date.calendarId, calendar);
|
||||
assert.sameValue(date.year, year);
|
||||
assert.sameValue(date.month, 1);
|
||||
|
@ -76,7 +65,5 @@ for (const test of tests) {
|
|||
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
||||
const dateMonth12 = date.with({ month: 12 });
|
||||
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
||||
assert.sameValue(isoYear, isoFields.isoYear);
|
||||
assert.sameValue(isoMonth, isoFields.isoMonth);
|
||||
assert.sameValue(isoDay, isoFields.isoDay);
|
||||
assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date");
|
||||
}
|
||||
|
|
|
@ -15,61 +15,48 @@ const tests = [
|
|||
inLeapYear: true,
|
||||
daysInYear: 366,
|
||||
daysInMonth12: 30,
|
||||
isoYear: 2016,
|
||||
isoMonth: 3,
|
||||
isoDay: 20
|
||||
isoDate: "2016-03-20",
|
||||
},
|
||||
{
|
||||
testYear: 1396,
|
||||
inLeapYear: false,
|
||||
daysInYear: 365,
|
||||
daysInMonth12: 29,
|
||||
isoYear: 2017,
|
||||
isoMonth: 3,
|
||||
isoDay: 21
|
||||
isoDate: "2017-03-21",
|
||||
},
|
||||
{
|
||||
testYear: 1397,
|
||||
inLeapYear: false,
|
||||
daysInYear: 365,
|
||||
daysInMonth12: 29,
|
||||
isoYear: 2018,
|
||||
isoMonth: 3,
|
||||
isoDay: 21
|
||||
isoDate: "2018-03-21",
|
||||
},
|
||||
{
|
||||
testYear: 1398,
|
||||
inLeapYear: false,
|
||||
daysInYear: 365,
|
||||
daysInMonth12: 29,
|
||||
isoYear: 2019,
|
||||
isoMonth: 3,
|
||||
isoDay: 21
|
||||
isoDate: "2019-03-21",
|
||||
},
|
||||
{
|
||||
testYear: 1399,
|
||||
inLeapYear: true,
|
||||
daysInYear: 366,
|
||||
daysInMonth12: 30,
|
||||
isoYear: 2020,
|
||||
isoMonth: 3,
|
||||
isoDay: 20
|
||||
isoDate: "2020-03-20",
|
||||
},
|
||||
{
|
||||
testYear: 1400,
|
||||
inLeapYear: false,
|
||||
daysInYear: 365,
|
||||
daysInMonth12: 29,
|
||||
isoYear: 2021,
|
||||
isoMonth: 3,
|
||||
isoDay: 21
|
||||
isoDate: "2021-03-21",
|
||||
}
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
const { testYear, inLeapYear, daysInYear, daysInMonth12, isoYear, isoMonth, isoDay } = test;
|
||||
const { testYear, inLeapYear, daysInYear, daysInMonth12, isoDate } = test;
|
||||
const date = Temporal.PlainDate.from({ year: testYear, month: 1, day: 1, calendar: "persian" });
|
||||
const isoFields = date.getISOFields();
|
||||
assert.sameValue(date.calendarId, "persian");
|
||||
assert.sameValue(date.year, testYear);
|
||||
assert.sameValue(date.month, 1);
|
||||
|
@ -84,7 +71,5 @@ for (const test of tests) {
|
|||
assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear);
|
||||
const dateMonth12 = date.with({ month: 12 });
|
||||
assert.sameValue(dateMonth12.daysInMonth, daysInMonth12);
|
||||
assert.sameValue(isoYear, isoFields.isoYear);
|
||||
assert.sameValue(isoMonth, isoFields.isoMonth);
|
||||
assert.sameValue(isoDay, isoFields.isoDay);
|
||||
assert.sameValue(date.toString(), `${isoDate}[u-ca=persian]`, "ISO reference date");
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ assert.sameValue(`${ zdt.toPlainDate() }`, "2019-10-29");
|
|||
|
||||
// preserves the calendar
|
||||
var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO("-07:00").withCalendar("gregory");
|
||||
assert.sameValue(zdt.toPlainDate().getISOFields().calendar, "gregory");
|
||||
assert.sameValue(zdt.toPlainDate().calendarId, "gregory");
|
||||
|
|
|
@ -16,5 +16,5 @@ assert.sameValue(`${ zdt.withCalendar("japanese") }`, "2019-11-18T15:23:30.12345
|
|||
var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00][u-ca=iso8601]");
|
||||
var zdt2 = zdt.withCalendar("japanese");
|
||||
assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds);
|
||||
assert.sameValue(zdt2.getISOFields().calendar, "japanese");
|
||||
assert.sameValue(zdt2.calendarId, "japanese");
|
||||
assert.sameValue(zdt2.timeZoneId, "+01:00");
|
||||
|
|
|
@ -11,6 +11,6 @@ features: [Temporal]
|
|||
var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]").withCalendar("gregory");
|
||||
var zdt2 = zdt.withTimeZone("-08:00");
|
||||
assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds);
|
||||
assert.sameValue(zdt2.getISOFields().calendar, "gregory");
|
||||
assert.sameValue(zdt2.calendarId, "gregory");
|
||||
assert.sameValue(zdt2.timeZoneId, "-08:00");
|
||||
assert.notSameValue(`${ zdt.toPlainDateTime() }`, `${ zdt2.toPlainDateTime() }`);
|
||||
|
|
Loading…
Reference in New Issue