From 0d24724d243465269b955ebf08cb6d9d9e9dfac5 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 8 May 2024 17:07:56 -0700 Subject: [PATCH] Normative: Remove getCalendar/getTimeZone methods Calendars and time zones will be only strings, not objects. Therefore these methods that return the calendar or time zone as an object are not needed. See: #2826 --- docs/plaindate.md | 7 ------- docs/plaindatetime.md | 7 ------- docs/plainmonthday.md | 7 ------- docs/plainyearmonth.md | 7 ------- docs/zoneddatetime.md | 14 -------------- polyfill/index.d.ts | 6 ------ polyfill/lib/plaindate.mjs | 4 ---- polyfill/lib/plaindatetime.mjs | 4 ---- polyfill/lib/plainmonthday.mjs | 4 ---- polyfill/lib/plainyearmonth.mjs | 4 ---- polyfill/lib/zoneddatetime.mjs | 8 -------- spec/plaindate.html | 12 ------------ spec/plaindatetime.html | 12 ------------ spec/plainmonthday.html | 12 ------------ spec/plainyearmonth.html | 12 ------------ spec/zoneddatetime.html | 24 ------------------------ 16 files changed, 144 deletions(-) diff --git a/docs/plaindate.md b/docs/plaindate.md index 6624dd7da..17e78b972 100644 --- a/docs/plaindate.md +++ b/docs/plaindate.md @@ -747,13 +747,6 @@ date.toPlainYearMonth(); // => 2006-08 date.toPlainMonthDay(); // => 08-24 ``` -### date.**getCalendar**(): object - -**Returns:** a `Temporal.Calendar` instance or plain object representing the calendar in which `date` is reckoned. - -This method is mainly useful if you need an object on which to call calendar methods. -Most code will not need to use it. - ### date.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, calendar: string | object } **Returns:** a plain object with properties expressing `date` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) in which `date` is reckoned. diff --git a/docs/plaindatetime.md b/docs/plaindatetime.md index 7db32e55f..5ac58995e 100644 --- a/docs/plaindatetime.md +++ b/docs/plaindatetime.md @@ -941,13 +941,6 @@ dt.toPlainDate().toPlainYearMonth(); // => 1995-12 dt.toPlainDate().toPlainMonthDay(); // => 12-07 ``` -### datetime.**getCalendar**(): object - -**Returns:** a `Temporal.Calendar` instance or plain object representing the calendar in which `datetime` is reckoned. - -This method is mainly useful if you need an object on which to call calendar methods. -Most code will not need to use it. - ### datetime.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, isoHour: number, isoMinute: number, isoSecond: number, isoMillisecond: number, isoMicrosecond: number, isoNanosecond: number, calendar: string | object } **Returns:** a plain object with properties expressing `datetime` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) in which `datetime` is reckoned. diff --git a/docs/plainmonthday.md b/docs/plainmonthday.md index c24a64253..5c7b86a5b 100644 --- a/docs/plainmonthday.md +++ b/docs/plainmonthday.md @@ -390,13 +390,6 @@ md = Temporal.PlainMonthDay.from({ date = md.toPlainDate({ era: 'reiwa', eraYear: 2 }); // => 2020-01-01[u-ca=japanese] ``` -### monthDay.**getCalendar**(): object - -**Returns:** a `Temporal.Calendar` instance or plain object representing the calendar in which `monthDay` is reckoned. - -This method is mainly useful if you need an object on which to call calendar methods. -Most code will not need to use it. - ### monthDay.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, calendar: string | object } **Returns:** a plain object with properties expressing `monthDay` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) in which `monthDay` is reckoned. diff --git a/docs/plainyearmonth.md b/docs/plainyearmonth.md index 52ddf42bc..72ffb9970 100644 --- a/docs/plainyearmonth.md +++ b/docs/plainyearmonth.md @@ -578,13 +578,6 @@ ym = Temporal.PlainYearMonth.from('2019-06'); ym.toPlainDate({ day: 24 }); // => 2019-06-24 ``` -### yearMonth.**getCalendar**(): object - -**Returns:** a `Temporal.Calendar` instance or plain object representing the calendar in which `yearMonth` is reckoned. - -This method is mainly useful if you need an object on which to call calendar methods. -Most code will not need to use it. - ### yearMonth.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, calendar: string | object } **Returns:** a plain object with properties expressing `yearMonth` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) that `yearMonth` is reckoned in. diff --git a/docs/zoneddatetime.md b/docs/zoneddatetime.md index 2a6f9400e..8acd0174a 100644 --- a/docs/zoneddatetime.md +++ b/docs/zoneddatetime.md @@ -1357,20 +1357,6 @@ zdt.toPlainDate().toPlainYearMonth(); // => 1995-12 zdt.toPlainDate().toPlainMonthDay(); // => 12-07 ``` -### zonedDateTime.**getCalendar**(): object - -**Returns:** a `Temporal.Calendar` instance or plain object representing the calendar in which `zonedDateTime` is reckoned. - -This method is mainly useful if you need an object on which to call calendar methods. -Most code will not need to use it. - -### zonedDateTime.**getTimeZone**(): object - -**Returns:** a `Temporal.TimeZone` instance or plain object representing the time zone in which `zonedDateTime` is reckoned. - -This method is mainly useful if you need an object on which to call time zone methods. -Most code will not need to use it. - ### zonedDateTime.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, hour: number, minute: number, second: number, millisecond: number, microsecond: number, nanosecond: number, offset: string, timeZone: string | object, calendar: string | object } **Returns:** a plain object with properties expressing `zonedDateTime` in the ISO 8601 calendar, including all date/time fields as well as the `offset` property, and the calendar and time zone (which are usually strings, but may be objects) in which `zonedDateTime` is reckoned. diff --git a/polyfill/index.d.ts b/polyfill/index.d.ts index 4074865bd..7d3e70491 100644 --- a/polyfill/index.d.ts +++ b/polyfill/index.d.ts @@ -799,7 +799,6 @@ export namespace Temporal { readonly monthCode: string; readonly day: number; readonly calendarId: string; - getCalendar(): CalendarProtocol; readonly dayOfWeek: number; readonly dayOfYear: number; readonly weekOfYear: number | undefined; @@ -910,7 +909,6 @@ export namespace Temporal { readonly microsecond: number; readonly nanosecond: number; readonly calendarId: string; - getCalendar(): CalendarProtocol; readonly dayOfWeek: number; readonly dayOfYear: number; readonly weekOfYear: number | undefined; @@ -973,7 +971,6 @@ export namespace Temporal { readonly monthCode: string; readonly day: number; readonly calendarId: string; - getCalendar(): CalendarProtocol; equals(other: Temporal.PlainMonthDay | PlainMonthDayLike | string): boolean; with(monthDayLike: PlainMonthDayLike, options?: AssignmentOptions): Temporal.PlainMonthDay; toPlainDate(year: { year: number }): Temporal.PlainDate; @@ -1149,7 +1146,6 @@ export namespace Temporal { readonly month: number; readonly monthCode: string; readonly calendarId: string; - getCalendar(): CalendarProtocol; readonly daysInMonth: number; readonly daysInYear: number; readonly monthsInYear: number; @@ -1226,9 +1222,7 @@ export namespace Temporal { readonly microsecond: number; readonly nanosecond: number; readonly timeZoneId: string; - getTimeZone(): TimeZoneProtocol; readonly calendarId: string; - getCalendar(): CalendarProtocol; readonly dayOfWeek: number; readonly dayOfYear: number; readonly weekOfYear: number | undefined; diff --git a/polyfill/lib/plaindate.mjs b/polyfill/lib/plaindate.mjs index 0c3605caa..f7f78149f 100644 --- a/polyfill/lib/plaindate.mjs +++ b/polyfill/lib/plaindate.mjs @@ -223,10 +223,6 @@ export class PlainDate { isoYear: GetSlot(this, ISO_YEAR) }; } - getCalendar() { - if (!ES.IsTemporalDate(this)) throw new TypeError('invalid receiver'); - return ES.ToTemporalCalendarObject(GetSlot(this, CALENDAR)); - } static from(item, options = undefined) { options = ES.GetOptionsObject(options); diff --git a/polyfill/lib/plaindatetime.mjs b/polyfill/lib/plaindatetime.mjs index 399d5cfba..b71c4065e 100644 --- a/polyfill/lib/plaindatetime.mjs +++ b/polyfill/lib/plaindatetime.mjs @@ -383,10 +383,6 @@ export class PlainDateTime { isoYear: GetSlot(this, ISO_YEAR) }; } - getCalendar() { - if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver'); - return ES.ToTemporalCalendarObject(GetSlot(this, CALENDAR)); - } static from(item, options = undefined) { options = ES.GetOptionsObject(options); diff --git a/polyfill/lib/plainmonthday.mjs b/polyfill/lib/plainmonthday.mjs index da7c90469..2e76243f2 100644 --- a/polyfill/lib/plainmonthday.mjs +++ b/polyfill/lib/plainmonthday.mjs @@ -101,10 +101,6 @@ export class PlainMonthDay { isoYear: GetSlot(this, ISO_YEAR) }; } - getCalendar() { - if (!ES.IsTemporalMonthDay(this)) throw new TypeError('invalid receiver'); - return ES.ToTemporalCalendarObject(GetSlot(this, CALENDAR)); - } static from(item, options = undefined) { options = ES.GetOptionsObject(options); diff --git a/polyfill/lib/plainyearmonth.mjs b/polyfill/lib/plainyearmonth.mjs index 51400156b..c6ff3a825 100644 --- a/polyfill/lib/plainyearmonth.mjs +++ b/polyfill/lib/plainyearmonth.mjs @@ -133,10 +133,6 @@ export class PlainYearMonth { isoYear: GetSlot(this, ISO_YEAR) }; } - getCalendar() { - if (!ES.IsTemporalYearMonth(this)) throw new TypeError('invalid receiver'); - return ES.ToTemporalCalendarObject(GetSlot(this, CALENDAR)); - } static from(item, options = undefined) { options = ES.GetOptionsObject(options); diff --git a/polyfill/lib/zoneddatetime.mjs b/polyfill/lib/zoneddatetime.mjs index db52de974..d46ef19af 100644 --- a/polyfill/lib/zoneddatetime.mjs +++ b/polyfill/lib/zoneddatetime.mjs @@ -588,14 +588,6 @@ export class ZonedDateTime { timeZone: timeZoneRec.receiver }; } - getCalendar() { - if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); - return ES.ToTemporalCalendarObject(GetSlot(this, CALENDAR)); - } - getTimeZone() { - if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver'); - return ES.ToTemporalTimeZoneObject(GetSlot(this, TIME_ZONE)); - } static from(item, options = undefined) { options = ES.GetOptionsObject(options); diff --git a/spec/plaindate.html b/spec/plaindate.html index ee63e56ef..10c361d30 100644 --- a/spec/plaindate.html +++ b/spec/plaindate.html @@ -387,18 +387,6 @@

Temporal.PlainDate.prototype.getISOFields ( )

- -

Temporal.PlainDate.prototype.getCalendar ( )

-

- This method performs the following steps when called: -

- - 1. Let _temporalDate_ be the *this* value. - 1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]). - 1. Return ToTemporalCalendarObject(_temporalDate_.[[Calendar]]). - -
-

Temporal.PlainDate.prototype.add ( _temporalDurationLike_ [ , _options_ ] )

diff --git a/spec/plaindatetime.html b/spec/plaindatetime.html index 532ed628c..d936b6a8d 100644 --- a/spec/plaindatetime.html +++ b/spec/plaindatetime.html @@ -674,18 +674,6 @@

Temporal.PlainDateTime.prototype.getISOFields ( )

1. Return _fields_.
- - -

Temporal.PlainDateTime.prototype.getCalendar ( )

-

- This method performs the following steps when called: -

- - 1. Let _dateTime_ be the *this* value. - 1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]). - 1. Return ToTemporalCalendarObject(_dateTime_). - -
diff --git a/spec/plainmonthday.html b/spec/plainmonthday.html index 71d7649cc..71f2f304d 100644 --- a/spec/plainmonthday.html +++ b/spec/plainmonthday.html @@ -263,18 +263,6 @@

Temporal.PlainMonthDay.prototype.getISOFields ( )

1. Return _fields_.
- - -

Temporal.PlainMonthDay.prototype.getCalendar ( )

-

- This method performs the following steps when called: -

- - 1. Let _monthDay_ be the *this* value. - 1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]). - 1. Return ToTemporalCalendarObject(_monthDay_.[[Calendar]]). - -
diff --git a/spec/plainyearmonth.html b/spec/plainyearmonth.html index c76c36c41..829ab6a50 100644 --- a/spec/plainyearmonth.html +++ b/spec/plainyearmonth.html @@ -399,18 +399,6 @@

Temporal.PlainYearMonth.prototype.getISOFields ( )

1. Return _fields_.
- - -

Temporal.PlainYearMonth.prototype.getCalendar ( )

-

- This method performs the following steps when called: -

- - 1. Let _yearMonth_ be the *this* value. - 1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]). - 1. Return ToTemporalCalendarObject(_yearMonth_.[[Calendar]]). - -
diff --git a/spec/zoneddatetime.html b/spec/zoneddatetime.html index 0c42abf16..2e13a66fb 100644 --- a/spec/zoneddatetime.html +++ b/spec/zoneddatetime.html @@ -966,30 +966,6 @@

Temporal.ZonedDateTime.prototype.getISOFields ( )

1. Return _fields_.
- - -

Temporal.ZonedDateTime.prototype.getCalendar ( )

-

- This method performs the following steps when called: -

- - 1. Let _zonedDateTime_ be the *this* value. - 1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]). - 1. Return ToTemporalCalendarObject(_zonedDateTime_.[[Calendar]]). - -
- - -

Temporal.ZonedDateTime.prototype.getTimeZone ( )

-

- This method performs the following steps when called: -

- - 1. Let _zonedDateTime_ be the *this* value. - 1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]). - 1. Return ToTemporalTimeZoneObject(_zonedDateTime_.[[TimeZone]]). - -