Skip to content

Commit

Permalink
Temporal: Remove getCalendar and getTimeZone methods
Browse files Browse the repository at this point in the history
Temporarily replace them with getISOFields().calendar/timeZone just to
keep the tests running until we remove Calendar and TimeZone objects
altogether.

See: tc39/proposal-temporal#2826
  • Loading branch information
ptomato committed Jun 27, 2024
1 parent efb2c79 commit 405c23e
Show file tree
Hide file tree
Showing 65 changed files with 33 additions and 906 deletions.
3 changes: 1 addition & 2 deletions test/built-ins/Temporal/PlainDate/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ Object.defineProperty(Temporal.Calendar, "from", {
const calendar = new Temporal.Calendar("iso8601");
const plainDateWithObject = new Temporal.PlainDate(2020, 12, 24, calendar);
TemporalHelpers.assertPlainDate(plainDateWithObject, 2020, 12, "M12", 24, "with object");
assert.sameValue(plainDateWithObject.getCalendar(), calendar);
assert.sameValue(plainDateWithObject.getISOFields().calendar, calendar);

const plainDateWithString = new Temporal.PlainDate(2020, 12, 24, "iso8601");
TemporalHelpers.assertPlainDate(plainDateWithString, 2020, 12, "M12", 24, "with string");
assert.sameValue(plainDateWithString.getISOFields().calendar, "iso8601", "calendar slot should store a string");
assert.notSameValue(plainDateWithString.getCalendar(), calendar);
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ features: [Temporal]
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => {
const result = Temporal.PlainDate.from(datetime);
TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2);
assert.sameValue(result.getCalendar(), calendar, "calendar result");
assert.sameValue(result.getISOFields().calendar, calendar, "calendar result");
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TemporalHelpers.assertPlainDate(
);

assert.sameValue(
result.getCalendar(),
result.getISOFields().calendar,
calendar,
"Calendar is copied"
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ features: [Temporal]

TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar");
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
});

This file was deleted.

33 changes: 0 additions & 33 deletions test/built-ins/Temporal/PlainDate/prototype/getCalendar/builtin.js

This file was deleted.

25 changes: 0 additions & 25 deletions test/built-ins/Temporal/PlainDate/prototype/getCalendar/length.js

This file was deleted.

23 changes: 0 additions & 23 deletions test/built-ins/Temporal/PlainDate/prototype/getCalendar/name.js

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ features: [Temporal]
const calendar = TemporalHelpers.calendarThrowEverything();
const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar);
const result = plainDate.toPlainDateTime("11:30:23");
assert.sameValue(result.getCalendar(), calendar, "calendar");
assert.sameValue(result.getISOFields().calendar, calendar, "calendar");
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ const result = plainDate.toZonedDateTime({
});
assert.sameValue(result.epochNanoseconds, 957270600_000_000_000n);
assert.sameValue(result.timeZoneId, "UTC");
assert.sameValue(result.getCalendar(), calendar);
assert.sameValue(result.getISOFields().calendar, calendar);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CustomTimeZone extends Temporal.TimeZone {
super("UTC");
}
getPossibleInstantsFor(plainDateTime) {
assert.sameValue(plainDateTime.getCalendar(), calendar);
assert.sameValue(plainDateTime.getISOFields().calendar, calendar);
return [new Temporal.Instant(987654321_000_000_000n)];
}
}
Expand All @@ -24,5 +24,5 @@ const result = plainDate.toZonedDateTime({
plainTime: { hour: 12, minute: 30 },
});
assert.sameValue(result.epochNanoseconds, 987654321_000_000_000n);
assert.sameValue(result.getTimeZone(), timeZone);
assert.sameValue(result.getCalendar(), calendar);
assert.sameValue(result.getISOFields().timeZone, timeZone);
assert.sameValue(result.getISOFields().calendar, calendar);
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const calendar = Temporal.Calendar.from("iso8601");
const objectResult = plainDate.withCalendar(calendar);
assert.notSameValue(objectResult, plainDate, "object: new object");
TemporalHelpers.assertPlainDate(objectResult, 1976, 11, "M11", 18, "object");
assert.sameValue(objectResult.getCalendar(), calendar, "object: calendar");
assert.sameValue(objectResult.getISOFields().calendar, calendar, "object: calendar");

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

const originalCalendar = plainDate.getCalendar();
const originalCalendar = plainDate.getISOFields().calendar;
const sameResult = plainDate.withCalendar(originalCalendar);
assert.notSameValue(sameResult, plainDate, "original: new object");
TemporalHelpers.assertPlainDate(sameResult, 1976, 11, "M11", 18, "original");
assert.sameValue(sameResult.getCalendar(), originalCalendar, "original: calendar slot stores and object");
assert.sameValue(sameResult.getISOFields().calendar, originalCalendar, "original: calendar slot stores and object");
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ TemporalHelpers.checkSubclassingIgnored(
[customCalendar],
(result) => {
TemporalHelpers.assertPlainDate(result, 1900, 2, "M02", 5);
assert.sameValue(result.getCalendar(), customCalendar, "calendar result");
assert.sameValue(result.getISOFields().calendar, customCalendar, "calendar result");
},
);
2 changes: 1 addition & 1 deletion test/built-ins/Temporal/PlainDateTime/constructor-full.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDateTime(datetime,
);

assert.sameValue(
datetime.getCalendar(),
datetime.getISOFields().calendar,
calendar,
"calendar supplied in constructor can be extracted and is unchanged"
);
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ features: [Temporal]
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => {
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.getCalendar(), calendar, "calendar result");
assert.sameValue(result.getISOFields().calendar, calendar, "calendar result");
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ features: [Temporal]

TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar");
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
});

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 405c23e

Please sign in to comment.