Skip to content

Commit

Permalink
Normative: Remove getCalendar/getTimeZone methods
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ptomato committed May 25, 2024
1 parent 45921c3 commit 0d24724
Show file tree
Hide file tree
Showing 16 changed files with 0 additions and 144 deletions.
7 changes: 0 additions & 7 deletions docs/plaindate.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 0 additions & 7 deletions docs/plaindatetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 0 additions & 7 deletions docs/plainmonthday.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 0 additions & 7 deletions docs/plainyearmonth.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 0 additions & 14 deletions docs/zoneddatetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions polyfill/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions polyfill/lib/plaindate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions polyfill/lib/plaindatetime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions polyfill/lib/plainmonthday.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions polyfill/lib/plainyearmonth.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 0 additions & 8 deletions polyfill/lib/zoneddatetime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 0 additions & 12 deletions spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,6 @@ <h1>Temporal.PlainDate.prototype.getISOFields ( )</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.plaindate.prototype.getcalendar">
<h1>Temporal.PlainDate.prototype.getCalendar ( )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _temporalDate_ be the *this* value.
1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]).
1. Return ToTemporalCalendarObject(_temporalDate_.[[Calendar]]).
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.plaindate.prototype.add">
<h1>Temporal.PlainDate.prototype.add ( _temporalDurationLike_ [ , _options_ ] )</h1>
<p>
Expand Down
12 changes: 0 additions & 12 deletions spec/plaindatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -674,18 +674,6 @@ <h1>Temporal.PlainDateTime.prototype.getISOFields ( )</h1>
1. Return _fields_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.plaindatetime.prototype.getcalendar">
<h1>Temporal.PlainDateTime.prototype.getCalendar ( )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _dateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]).
1. Return ToTemporalCalendarObject(_dateTime_).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-temporal-plaindatetime-instances">
Expand Down
12 changes: 0 additions & 12 deletions spec/plainmonthday.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,6 @@ <h1>Temporal.PlainMonthDay.prototype.getISOFields ( )</h1>
1. Return _fields_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.plainmonthday.prototype.getcalendar">
<h1>Temporal.PlainMonthDay.prototype.getCalendar ( )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _monthDay_ be the *this* value.
1. Perform ? RequireInternalSlot(_monthDay_, [[InitializedTemporalMonthDay]]).
1. Return ToTemporalCalendarObject(_monthDay_.[[Calendar]]).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-temporal-plainmonthday-instances">
Expand Down
12 changes: 0 additions & 12 deletions spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,6 @@ <h1>Temporal.PlainYearMonth.prototype.getISOFields ( )</h1>
1. Return _fields_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.plainyearmonth.prototype.getcalendar">
<h1>Temporal.PlainYearMonth.prototype.getCalendar ( )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Return ToTemporalCalendarObject(_yearMonth_.[[Calendar]]).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-temporal-plainyearmonth-instances">
Expand Down
24 changes: 0 additions & 24 deletions spec/zoneddatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -966,30 +966,6 @@ <h1>Temporal.ZonedDateTime.prototype.getISOFields ( )</h1>
1. Return _fields_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.zoneddatetime.prototype.getcalendar">
<h1>Temporal.ZonedDateTime.prototype.getCalendar ( )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _zonedDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]).
1. Return ToTemporalCalendarObject(_zonedDateTime_.[[Calendar]]).
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal.zoneddatetime.prototype.gettimezone">
<h1>Temporal.ZonedDateTime.prototype.getTimeZone ( )</h1>
<p>
This method performs the following steps when called:
</p>
<emu-alg>
1. Let _zonedDateTime_ be the *this* value.
1. Perform ? RequireInternalSlot(_zonedDateTime_, [[InitializedTemporalZonedDateTime]]).
1. Return ToTemporalTimeZoneObject(_zonedDateTime_.[[TimeZone]]).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-temporal-zoneddatetime-instances">
Expand Down

0 comments on commit 0d24724

Please sign in to comment.