From 4d397ad967f24dcfacd8b03f8ff21ce9923d0bc1 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 18 Jan 2021 12:17:14 -0800 Subject: [PATCH] Remove CalendarToString abstract operation Also remove %Temporal.Calendar.prototype.toString% intrinsic. These are not needed because toString() is a required method of the Calendar protocol, so there should always be a toString() there to call. See: #1294 --- polyfill/lib/calendar.mjs | 5 ++--- polyfill/lib/ecmascript.mjs | 19 +++++++------------ polyfill/lib/intl.mjs | 10 +++++----- polyfill/lib/plaindate.mjs | 10 +++++----- polyfill/lib/plaindatetime.mjs | 10 +++++----- polyfill/lib/plainmonthday.mjs | 2 +- polyfill/lib/plainyearmonth.mjs | 10 +++++----- polyfill/lib/zoneddatetime.mjs | 10 +++++----- spec/calendar.html | 28 ++++++++-------------------- spec/intl.html | 10 +++++----- spec/plaindate.html | 18 +++++------------- spec/plaindatetime.html | 18 +++++------------- spec/plainmonthday.html | 2 +- spec/plaintime.html | 2 +- spec/plainyearmonth.html | 14 +++----------- spec/zoneddatetime.html | 2 +- 16 files changed, 64 insertions(+), 106 deletions(-) diff --git a/polyfill/lib/calendar.mjs b/polyfill/lib/calendar.mjs index 7f9e4a7e08..17bdb20184 100644 --- a/polyfill/lib/calendar.mjs +++ b/polyfill/lib/calendar.mjs @@ -33,7 +33,7 @@ export class Calendar { } } get id() { - return ES.CalendarToString(this); + return ES.ToString(this); } dateFromFields(fields, options, constructor) { if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver'); @@ -143,7 +143,7 @@ export class Calendar { return GetSlot(this, CALENDAR_ID); } toJSON() { - return ES.CalendarToString(this); + return ES.ToString(this); } static from(item) { if (ES.Type(item) === 'Object') { @@ -167,7 +167,6 @@ export class Calendar { MakeIntrinsicClass(Calendar, 'Temporal.Calendar'); DefineIntrinsic('Temporal.Calendar.from', Calendar.from); DefineIntrinsic('Temporal.Calendar.prototype.fields', Calendar.prototype.fields); -DefineIntrinsic('Temporal.Calendar.prototype.toString', Calendar.prototype.toString); impl['iso8601'] = { dateFromFields(fields, overflow) { diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index d47d7c79ba..71c62c8ae0 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -1246,7 +1246,7 @@ export const ES = ObjectAssign({}, ES2020, { calendar = item.calendar; if (calendar) { calendar = ES.ToTemporalCalendar(calendar); - if (ES.CalendarToString(calendar) !== 'iso8601') { + if (ES.ToString(calendar) !== 'iso8601') { throw new RangeError('PlainTime can only have iso8601 calendar'); } } @@ -1449,11 +1449,6 @@ export const ES = ObjectAssign({}, ES2020, { const array = ES.Call(fields, calendar, [fieldNames]); return ES.CreateListFromArrayLike(array, ['String']); }, - CalendarToString: (calendar) => { - let toString = calendar.toString; - if (toString === undefined) toString = GetIntrinsic('%Temporal.Calendar.prototype.toString%'); - return ES.ToString(ES.Call(toString, calendar)); - }, ToTemporalCalendar: (calendarLike) => { if (ES.Type(calendarLike) === 'Object') { @@ -1463,18 +1458,18 @@ export const ES = ObjectAssign({}, ES2020, { return ES.CalendarFrom(identifier); }, CalendarCompare: (one, two) => { - const cal1 = ES.CalendarToString(one); - const cal2 = ES.CalendarToString(two); + const cal1 = ES.ToString(one); + const cal2 = ES.ToString(two); return cal1 < cal2 ? -1 : cal1 > cal2 ? 1 : 0; }, CalendarEquals: (one, two) => { - const cal1 = ES.CalendarToString(one); - const cal2 = ES.CalendarToString(two); + const cal1 = ES.ToString(one); + const cal2 = ES.ToString(two); return cal1 === cal2; }, ConsolidateCalendars: (one, two) => { - const sOne = ES.CalendarToString(one); - const sTwo = ES.CalendarToString(two); + const sOne = ES.ToString(one); + const sTwo = ES.ToString(two); if (sOne === sTwo || sOne === 'iso8601') { return two; } else if (sTwo === 'iso8601') { diff --git a/polyfill/lib/intl.mjs b/polyfill/lib/intl.mjs index 13b41ca949..db91afd1bd 100644 --- a/polyfill/lib/intl.mjs +++ b/polyfill/lib/intl.mjs @@ -278,7 +278,7 @@ function extractOverrides(temporalObj, main) { const isoYear = GetSlot(temporalObj, ISO_YEAR); const isoMonth = GetSlot(temporalObj, ISO_MONTH); const referenceISODay = GetSlot(temporalObj, ISO_DAY); - const calendar = ES.CalendarToString(GetSlot(temporalObj, CALENDAR)); + const calendar = ES.ToString(GetSlot(temporalObj, CALENDAR)); if (calendar !== main[CAL_ID]) { throw new RangeError( `cannot format PlainYearMonth with calendar ${calendar} in locale with calendar ${main[CAL_ID]}` @@ -295,7 +295,7 @@ function extractOverrides(temporalObj, main) { const referenceISOYear = GetSlot(temporalObj, ISO_YEAR); const isoMonth = GetSlot(temporalObj, ISO_MONTH); const isoDay = GetSlot(temporalObj, ISO_DAY); - const calendar = ES.CalendarToString(GetSlot(temporalObj, CALENDAR)); + const calendar = ES.ToString(GetSlot(temporalObj, CALENDAR)); if (calendar !== main[CAL_ID]) { throw new RangeError( `cannot format PlainMonthDay with calendar ${calendar} in locale with calendar ${main[CAL_ID]}` @@ -312,7 +312,7 @@ function extractOverrides(temporalObj, main) { const isoYear = GetSlot(temporalObj, ISO_YEAR); const isoMonth = GetSlot(temporalObj, ISO_MONTH); const isoDay = GetSlot(temporalObj, ISO_DAY); - const calendar = ES.CalendarToString(GetSlot(temporalObj, CALENDAR)); + const calendar = ES.ToString(GetSlot(temporalObj, CALENDAR)); if (calendar !== 'iso8601' && calendar !== main[CAL_ID]) { throw new RangeError(`cannot format PlainDate with calendar ${calendar} in locale with calendar ${main[CAL_ID]}`); } @@ -333,7 +333,7 @@ function extractOverrides(temporalObj, main) { const millisecond = GetSlot(temporalObj, ISO_MILLISECOND); const microsecond = GetSlot(temporalObj, ISO_MICROSECOND); const nanosecond = GetSlot(temporalObj, ISO_NANOSECOND); - const calendar = ES.CalendarToString(GetSlot(temporalObj, CALENDAR)); + const calendar = ES.ToString(GetSlot(temporalObj, CALENDAR)); if (calendar !== 'iso8601' && calendar !== main[CAL_ID]) { throw new RangeError( `cannot format PlainDateTime with calendar ${calendar} in locale with calendar ${main[CAL_ID]}` @@ -361,7 +361,7 @@ function extractOverrides(temporalObj, main) { } if (ES.IsTemporalZonedDateTime(temporalObj)) { - const calendar = ES.CalendarToString(GetSlot(temporalObj, CALENDAR)); + const calendar = ES.ToString(GetSlot(temporalObj, CALENDAR)); if (calendar !== 'iso8601' && calendar !== main[CAL_ID]) { throw new RangeError( `cannot format ZonedDateTime with calendar ${calendar} in locale with calendar ${main[CAL_ID]}` diff --git a/polyfill/lib/plaindate.mjs b/polyfill/lib/plaindate.mjs index 132a085da6..8c721706a7 100644 --- a/polyfill/lib/plaindate.mjs +++ b/polyfill/lib/plaindate.mjs @@ -27,7 +27,7 @@ function TemporalDateToString(date, showCalendar = 'auto') { const year = ES.ISOYearString(GetSlot(date, ISO_YEAR)); const month = ES.ISODateTimePartString(GetSlot(date, ISO_MONTH)); const day = ES.ISODateTimePartString(GetSlot(date, ISO_DAY)); - const calendarID = ES.CalendarToString(GetSlot(date, CALENDAR)); + const calendarID = ES.ToString(GetSlot(date, CALENDAR)); const calendar = ES.FormatCalendarAnnotation(calendarID, showCalendar); return `${year}-${month}-${day}${calendar}`; } @@ -179,8 +179,8 @@ export class PlainDate { other = ES.ToTemporalDate(other, PlainDate); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarId = ES.CalendarToString(calendar); - const otherCalendarId = ES.CalendarToString(otherCalendar); + const calendarId = ES.ToString(calendar); + const otherCalendarId = ES.ToString(otherCalendar); if (calendarId !== otherCalendarId) { throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`); } @@ -236,8 +236,8 @@ export class PlainDate { other = ES.ToTemporalDate(other, PlainDate); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarId = ES.CalendarToString(calendar); - const otherCalendarId = ES.CalendarToString(otherCalendar); + const calendarId = ES.ToString(calendar); + const otherCalendarId = ES.ToString(otherCalendar); if (calendarId !== otherCalendarId) { throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`); } diff --git a/polyfill/lib/plaindatetime.mjs b/polyfill/lib/plaindatetime.mjs index e501b0ce45..8bd989eadf 100644 --- a/polyfill/lib/plaindatetime.mjs +++ b/polyfill/lib/plaindatetime.mjs @@ -58,7 +58,7 @@ function DateTimeToString(dateTime, precision, showCalendar = 'auto', options = hour = ES.ISODateTimePartString(hour); minute = ES.ISODateTimePartString(minute); const seconds = ES.FormatSecondsStringPart(second, millisecond, microsecond, nanosecond, precision); - const calendarID = ES.CalendarToString(GetSlot(dateTime, CALENDAR)); + const calendarID = ES.ToString(GetSlot(dateTime, CALENDAR)); const calendar = ES.FormatCalendarAnnotation(calendarID, showCalendar); return `${year}-${month}-${day}T${hour}:${minute}${seconds}${calendar}`; } @@ -412,8 +412,8 @@ export class PlainDateTime { other = ES.ToTemporalDateTime(other, PlainDateTime); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarId = ES.CalendarToString(calendar); - const otherCalendarId = ES.CalendarToString(otherCalendar); + const calendarId = ES.ToString(calendar); + const otherCalendarId = ES.ToString(otherCalendar); if (calendarId !== otherCalendarId) { throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`); } @@ -505,8 +505,8 @@ export class PlainDateTime { other = ES.ToTemporalDateTime(other, PlainDateTime); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarId = ES.CalendarToString(calendar); - const otherCalendarId = ES.CalendarToString(otherCalendar); + const calendarId = ES.ToString(calendar); + const otherCalendarId = ES.ToString(otherCalendar); if (calendarId !== otherCalendarId) { throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`); } diff --git a/polyfill/lib/plainmonthday.mjs b/polyfill/lib/plainmonthday.mjs index a6885381c6..c107e0289f 100644 --- a/polyfill/lib/plainmonthday.mjs +++ b/polyfill/lib/plainmonthday.mjs @@ -12,7 +12,7 @@ function MonthDayToString(monthDay, showCalendar = 'auto') { const day = ES.ISODateTimePartString(GetSlot(monthDay, ISO_DAY)); let resultString = `${month}-${day}`; const calendar = GetSlot(monthDay, CALENDAR); - const calendarID = ES.CalendarToString(calendar); + const calendarID = ES.ToString(calendar); if (calendarID !== 'iso8601') { const year = ES.ISOYearString(GetSlot(monthDay, ISO_YEAR)); resultString = `${year}-${resultString}`; diff --git a/polyfill/lib/plainyearmonth.mjs b/polyfill/lib/plainyearmonth.mjs index a7a4d27db7..4d182be198 100644 --- a/polyfill/lib/plainyearmonth.mjs +++ b/polyfill/lib/plainyearmonth.mjs @@ -12,7 +12,7 @@ function YearMonthToString(yearMonth, showCalendar = 'auto') { const month = ES.ISODateTimePartString(GetSlot(yearMonth, ISO_MONTH)); let resultString = `${year}-${month}`; const calendar = GetSlot(yearMonth, CALENDAR); - const calendarID = ES.CalendarToString(calendar); + const calendarID = ES.ToString(calendar); if (calendarID !== 'iso8601') { const day = ES.ISODateTimePartString(GetSlot(yearMonth, ISO_DAY)); resultString += `-${day}`; @@ -175,8 +175,8 @@ export class PlainYearMonth { other = ES.ToTemporalYearMonth(other, PlainYearMonth); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarID = ES.CalendarToString(calendar); - const otherCalendarID = ES.CalendarToString(otherCalendar); + const calendarID = ES.ToString(calendar); + const otherCalendarID = ES.ToString(otherCalendar); if (calendarID !== otherCalendarID) { throw new RangeError( `cannot compute difference between months of ${calendarID} and ${otherCalendarID} calendars` @@ -248,8 +248,8 @@ export class PlainYearMonth { other = ES.ToTemporalYearMonth(other, PlainYearMonth); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarID = ES.CalendarToString(calendar); - const otherCalendarID = ES.CalendarToString(otherCalendar); + const calendarID = ES.ToString(calendar); + const otherCalendarID = ES.ToString(otherCalendar); if (calendarID !== otherCalendarID) { throw new RangeError( `cannot compute difference between months of ${calendarID} and ${otherCalendarID} calendars` diff --git a/polyfill/lib/zoneddatetime.mjs b/polyfill/lib/zoneddatetime.mjs index 55283caeea..576a1f1701 100644 --- a/polyfill/lib/zoneddatetime.mjs +++ b/polyfill/lib/zoneddatetime.mjs @@ -405,8 +405,8 @@ export class ZonedDateTime { other = ES.ToTemporalZonedDateTime(other, ZonedDateTime); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarId = ES.CalendarToString(calendar); - const otherCalendarId = ES.CalendarToString(otherCalendar); + const calendarId = ES.ToString(calendar); + const otherCalendarId = ES.ToString(otherCalendar); if (calendarId !== otherCalendarId) { throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`); } @@ -528,8 +528,8 @@ export class ZonedDateTime { other = ES.ToTemporalZonedDateTime(other, ZonedDateTime); const calendar = GetSlot(this, CALENDAR); const otherCalendar = GetSlot(other, CALENDAR); - const calendarId = ES.CalendarToString(calendar); - const otherCalendarId = ES.CalendarToString(otherCalendar); + const calendarId = ES.ToString(calendar); + const otherCalendarId = ES.ToString(otherCalendar); if (calendarId !== otherCalendarId) { throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`); } @@ -911,7 +911,7 @@ function zonedDateTimeToString( let result = `${year}-${month}-${day}T${hour}:${minute}${seconds}`; if (showOffset !== 'never') result += ES.GetOffsetStringFor(tz, instant); if (showTimeZone !== 'never') result += `[${ES.TimeZoneToString(tz)}]`; - const calendarID = ES.CalendarToString(GetSlot(zdt, CALENDAR)); + const calendarID = ES.ToString(GetSlot(zdt, CALENDAR)); result += ES.FormatCalendarAnnotation(calendarID, showCalendar); return result; } diff --git a/spec/calendar.html b/spec/calendar.html index fb6a36ac8a..f95b006b61 100644 --- a/spec/calendar.html +++ b/spec/calendar.html @@ -35,15 +35,6 @@

GetISO8601Calendar ( )

- -

CalendarToString ( _calendar_ )

- - 1. Let _toString_ be ? Get(_calendar_, *"toString"*). - 1. If _toString_ is *undefined*, set _toString_ to %Temporal.Calendar.prototype.toString%. - 1. Return ? ToString(? Call(_toString_ , _calendar_, « »)). - -
-

CalendarFields ( _calendar_, _fieldNames_ )

@@ -209,8 +200,8 @@

FormatCalendarAnnotation ( _id_, _showCalendar_ )

CompareCalendar ( _one_, _two_ )

- 1. Let _calendarOne_ be ? CalendarToString(_one_). - 1. Let _calendarTwo_ be ? CalendarToString(_two_). + 1. Let _calendarOne_ be ? ToString(_one_). + 1. Let _calendarTwo_ be ? ToString(_two_). 1. Let _r_ be the result of performing Abstract Relational Comparison _calendarOne_ < _calendarTwo_. 1. If _r_ is *true*, return −1. 1. Let _r_ be the result of performing Abstract Relational Comparison _calendarTwo_ < _calendarOne_. @@ -222,8 +213,8 @@

CompareCalendar ( _one_, _two_ )

CalendarEquals ( _one_, _two_ )

- 1. Let _calendarOne_ be ? CalendarToString(_one_). - 1. Let _calendarTwo_ be ? CalendarToString(_two_). + 1. Let _calendarOne_ be ? ToString(_one_). + 1. Let _calendarTwo_ be ? ToString(_two_). 1. If _calendarOne_ is _calendarTwo_, return *true*. 1. Return *false*. @@ -232,8 +223,8 @@

CalendarEquals ( _one_, _two_ )

ConsolidateCalendars ( _one_, _two_ )

- 1. Let _calendarOne_ be ? CalendarToString(_one_). - 1. Let _calendarTwo_ be ? CalendarToString(_two_). + 1. Let _calendarOne_ be ? ToString(_one_). + 1. Let _calendarTwo_ be ? ToString(_two_). 1. If _calendarOne_ is _calendarTwo_, return _two_. 1. If _calendarOne_ is *"iso8601"*, return _two_. 1. If _calendarTwo_ is *"iso8601"*, return _one_. @@ -514,7 +505,7 @@

get Temporal.Calendar.prototype.id

1. Let _calendar_ be the *this* value. - 1. Return ? CalendarToString(_calendar_). + 1. Return ? ToString(_calendar_).
@@ -867,9 +858,6 @@

Temporal.Calendar.prototype.toString ( )

1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]). 1. Return _calendar_.[[Identifier]].
-

- This function is the %Temporal.Calendar.prototype.toString% intrinsic object. -

@@ -879,7 +867,7 @@

Temporal.Calendar.prototype.toJSON ( )

1. Let _calendar_ be the *this* value. - 1. Return ? CalendarToString(_calendar_). + 1. Return ? ToString(_calendar_).
diff --git a/spec/intl.html b/spec/intl.html index a225e84b1c..aa430252f2 100644 --- a/spec/intl.html +++ b/spec/intl.html @@ -300,7 +300,7 @@

PartitionDateTimePattern ( _dateTimeFormat_, _x_ )

1. TODO: _era_, _dayPeriod_, _fractionalSecondDigits_. 1. If _x_ has an [[InitializedTemporalDate]] internal slot, then 1. Let _pattern_ be _dateTimeFormat_.[[TemporalPlainDatePattern]]. - 1. Let _calendar_ be ? CalendarToString(_x_.[[Calendar]]). + 1. Let _calendar_ be ? ToString(_x_.[[Calendar]]). 1. If _calendar_ is _dateTimeFormat_.[[Calendar]], then 1. Let _calendarOverride_ be _x_.[[Calendar]]. 1. Else if _calendar_ is *"iso8601"*, then @@ -311,14 +311,14 @@

PartitionDateTimePattern ( _dateTimeFormat_, _x_ )

1. Let _instant_ be ? GetTemporalInstantFor(_timeZone_, _plainDateTime_, *"reject"*). 1. If _x_ has an [[InitializedTemporalYearMonth]] internal slot, then 1. Let _pattern_ be _dateTimeFormat_.[[TemporalPlainYearMonthPattern]]. - 1. Let _calendar_ be ? CalendarToString(_x_.[[Calendar]]). + 1. Let _calendar_ be ? ToString(_x_.[[Calendar]]). 1. If _calendar_ is not equal to _dateTimeFormat_.[[Calendar]], then 1. Throw a *RangeError* exception. 1. Let _plainDateTime_ be ? CreateTemporalDateTime(_x_.[[ISOYear]], _x_.[[ISOMonth]], _x_.[[ISODay]], 12, 0, 0, 0, 0, 0, _x_.[[Calendar]]). 1. Let _instant_ be ? GetTemporalInstantFor(_timeZone_, _plainDateTime_, *"reject"*). 1. If _x_ has an [[InitializedTemporalMonthDay]] internal slot, then 1. Let _pattern_ be _dateTimeFormat_.[[TemporalPlainMonthDayPattern]]. - 1. Let _calendar_ be ? CalendarToString(_x_.[[Calendar]]). + 1. Let _calendar_ be ? ToString(_x_.[[Calendar]]). 1. If _calendar_ is not equal to _dateTimeFormat_.[[Calendar]], then 1. Throw a *RangeError* exception. 1. Let _plainDateTime_ be ? CreateTemporalDateTime(_x_.[[ISOYear]], _x_.[[ISOMonth]], _x_.[[ISODay]], 12, 0, 0, 0, 0, 0, _x_.[[Calendar]]). @@ -330,7 +330,7 @@

PartitionDateTimePattern ( _dateTimeFormat_, _x_ )

1. Let _instant_ be ? GetTemporalInstantFor(_timeZone_, _plainDateTime_, *"reject"*). 1. If _x_ has an [[InitializedTemporalDateTime]] internal slot, then 1. Let _pattern_ be _dateTimeFormat_.[[TemporalPlainDateTimePattern]]. - 1. Let _calendar_ be ? CalendarToString(_x_.[[Calendar]]). + 1. Let _calendar_ be ? ToString(_x_.[[Calendar]]). 1. If _calendar_ is not *"iso8601"* and not equal to _dateTimeFormat_.[[Calendar]], then 1. Throw a *RangeError* exception. 1. Let _instant_ be ? GetTemporalInstantFor(_timeZone_, _x_, *"reject"*). @@ -339,7 +339,7 @@

PartitionDateTimePattern ( _dateTimeFormat_, _x_ )

1. Let _instant_ be _x_. 1. If _x_ has an [[InitializedTemporalZonedDateTime]] internal slot, then 1. Let _pattern_ be _dateTimeFormat_.[[TemporalZonedDateTimePattern]]. - 1. Let _calendar_ be ? CalendarToString(_x_.[[Calendar]]). + 1. Let _calendar_ be ? ToString(_x_.[[Calendar]]). 1. If _calendar_ is not *"iso8601"* and not equal to _dateTimeFormat_.[[Calendar]], then 1. Throw a *RangeError* exception. 1. Let _timeZone_ be ? TimeZoneToString(_x_.[[TimeZone]]). diff --git a/spec/plaindate.html b/spec/plaindate.html index 9304ca089a..495f9126eb 100644 --- a/spec/plaindate.html +++ b/spec/plaindate.html @@ -458,11 +458,7 @@

Temporal.PlainDate.prototype.until ( _other_ [ , _options_ ] )

1. Let _temporalDate_ be the *this* value. 1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]). 1. Set _other_ to ? ToTemporalDate(_other_). - 1. Let _calendar_ be _temporalDate_.[[Calendar]]. - 1. Let _calendarID_ be ? CalendarToString(_calendar_). - 1. Let _otherCalendar_ be _other_.[[Calendar]]. - 1. Let _otherCalendarID_ be ? CalendarToString(_otherCalendar_). - 1. If _calendarID_ ≠ _otherCalendarID_, throw a *RangeError* exception. + 1. If ? CalendarEquals(_temporalDate_.[[Calendar]], _other_.[[Calendar]]) is *false*, throw a *RangeError* exception. 1. Set _options_ to ? NormalizeOptionsObject(_options_). 1. Let _disallowedUnits_ be « *"hours"*, *"minutes"*, *"seconds"*, *"milliseconds"*, *"microseconds"*, *"nanoseconds"* ». 1. Let _smallestUnit_ be ? ToSmallestTemporalDurationUnit(_options_, *"days"*, _disallowedUnits_). @@ -470,7 +466,7 @@

Temporal.PlainDate.prototype.until ( _other_ [ , _options_ ] )

1. Perform ? ValidateTemporalUnitRange(_largestUnit_, _smallestUnit_). 1. Let _roundingMode_ be ? ToTemporalRoundingMode(_options_, *"trunc"*). 1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, *undefined*, *false*). - 1. Let _result_ be ? CalendarDateUntil(_calendar_, _temporalDate_, _other_, _largestUnit_). + 1. Let _result_ be ? CalendarDateUntil(_temporalDate_.[[Calendar]], _temporalDate_, _other_, _largestUnit_). 1. If _smallestUnit_ is not *"days"* or _roundingIncrement_ ≠ 1, then 1. Let _relativeTo_ be ! CreateTemporalDateTime(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]], 0, 0, 0, 0, 0, 0, _temporalDate_.[[Calendar]]). 1. Set _result_ to ? RoundDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], 0, 0, 0, 0, 0, 0, _roundingIncrement_, _smallestUnit_, _roundingMode_, _relativeTo_). @@ -488,11 +484,7 @@

Temporal.PlainDate.prototype.since ( _other_ [ , _options_ ] )

1. Let _temporalDate_ be the *this* value. 1. Perform ? RequireInternalSlot(_temporalDate_, [[InitializedTemporalDate]]). 1. Set _other_ to ? ToTemporalDate(_other_). - 1. Let _calendar_ be _temporalDate_.[[Calendar]]. - 1. Let _calendarID_ be ? CalendarToString(_calendar_). - 1. Let _otherCalendar_ be _other_.[[Calendar]]. - 1. Let _otherCalendarID_ be ? CalendarToString(_otherCalendar_). - 1. If _calendarID_ ≠ _otherCalendarID_, throw a *RangeError* exception. + 1. If ? CalendarEquals(_temporalDate_.[[Calendar]], _other_.[[Calendar]]) is *false*, throw a *RangeError* exception. 1. Set _options_ to ? NormalizeOptionsObject(_options_). 1. Let _disallowedUnits_ be « *"hours"*, *"minutes"*, *"seconds"*, *"milliseconds"*, *"microseconds"*, *"nanoseconds"* ». 1. Let _smallestUnit_ be ? ToSmallestTemporalDurationUnit(_options_, *"days"*, _disallowedUnits_). @@ -501,7 +493,7 @@

Temporal.PlainDate.prototype.since ( _other_ [ , _options_ ] )

1. Let _roundingMode_ be ? ToTemporalRoundingMode(_options_, *"trunc"*). 1. Set _roundingMode_ to ! NegateTemporalRoundingMode(_roundingMode_). 1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, *undefined*, *false*). - 1. Let _result_ be ? CalendarDateUntil(_calendar_, _other_, _temporalDate_, _largestUnit_). + 1. Let _result_ be ? CalendarDateUntil(_temporalDate_.[[Calendar]], _other_, _temporalDate_, _largestUnit_). 1. If _smallestUnit_ is *"days"* and _roundingIncrement_ = 1, then 1. Return ? CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], _result_.[[Weeks]], _result_.[[Days]], 0, 0, 0, 0, 0, 0). 1. Let _relativeTo_ be ! CreateTemporalDateTime(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]], 0, 0, 0, 0, 0, 0, _temporalDate_.[[Calendar]]). @@ -987,7 +979,7 @@

TemporalDateToString ( _temporalDate_, _showCalendar_ )

1. Let _year_ be ! PadYear(_temporalDate_.[[ISOYear]]). 1. Let _month_ be _temporalDate_.[[ISOMonth]] formatted as a two-digit decimal number, padded to the left with a zero if necessary. 1. Let _day_ be _temporalDate_.[[ISODay]] formatted as a two-digit decimal number, padded to the left with a zero if necessary. - 1. Let _calendarID_ be ? CalendarToString(_temporalDate_.[[Calendar]]). + 1. Let _calendarID_ be ? ToString(_temporalDate_.[[Calendar]]). 1. Let _calendar_ be ? FormatCalendarAnnotation(_calendarID_, _showCalendar_). 1. Return the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), _month_, the code unit 0x002D (HYPHEN-MINUS), _day_, and _calendar_. diff --git a/spec/plaindatetime.html b/spec/plaindatetime.html index 3229c6f3db..3bcb0f3dde 100644 --- a/spec/plaindatetime.html +++ b/spec/plaindatetime.html @@ -506,11 +506,7 @@

Temporal.PlainDateTime.prototype.until ( _other_ [ , _options_ ] )

1. Let _dateTime_ be the *this* value. 1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]). 1. Set _other_ to ? ToTemporalDateTime(_other_). - 1. Let _calendar_ be _temporalDate_.[[Calendar]]. - 1. Let _calendarID_ be ? CalendarToString(_calendar_). - 1. Let _otherCalendar_ be _other_.[[Calendar]]. - 1. Let _otherCalendarID_ be ? CalendarToString(_otherCalendar_). - 1. If _calendarID_ ≠ _otherCalendarID_, throw a *RangeError* exception. + 1. If ? CalendarEquals(_dateTime_.[[Calendar]], _other_.[[Calendar]]) is *false*, throw a *RangeError* exception. 1. Set _options_ to ? NormalizeOptionsObject(_options_). 1. Let _smallestUnit_ be ? ToSmallestTemporalDurationUnit(_options_, « », *"nanoseconds"*). 1. Let _defaultLargestUnit_ be ! LargerOfTwoTemporalDurationUnits(*"days"*, _smallestUnit_). @@ -519,7 +515,7 @@

Temporal.PlainDateTime.prototype.until ( _other_ [ , _options_ ] )

1. Let _roundingMode_ be ? ToTemporalRoundingMode(_options_, *"trunc"*). 1. Let _maximum_ be ! MaximumTemporalDurationRoundingIncrement(_smallestUnit_). 1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, _maximum_, *false*). - 1. Let _diff_ be ? DifferenceDateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _other_.[[ISOYear]], _other_.[[ISOMonth]], _other_.[[ISODay]], _other_.[[ISOHour]], _other_.[[ISOMinute]], _other_.[[ISOSecond]], _other_.[[ISOMillisecond]], _other_.[[ISOMicrosecond]], _other_.[[ISONanosecond]], _calendar_, _largestUnit_). + 1. Let _diff_ be ? DifferenceDateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _other_.[[ISOYear]], _other_.[[ISOMonth]], _other_.[[ISODay]], _other_.[[ISOHour]], _other_.[[ISOMinute]], _other_.[[ISOSecond]], _other_.[[ISOMillisecond]], _other_.[[ISOMicrosecond]], _other_.[[ISONanosecond]], _dateTime_.[[Calendar]], _largestUnit_). 1. Let _roundResult_ be ? RoundDuration(_diff_.[[Years]], _diff_.[[Months]], _diff_.[[Weeks]], _diff_.[[Days]], _diff_.[[Hours]], _diff_.[[Minutes]], _diff_.[[Seconds]], _diff_.[[Milliseconds]], _diff_.[[Microseconds]], _diff_.[[Nanoseconds]], _roundingIncrement_, _smallestUnit_, _roundingMode_, _dateTime_). 1. Let _result_ be ! BalanceDuration(_roundResult_.[[Days]], _roundResult_.[[Hours]], _roundResult_.[[Minutes]], _roundResult_.[[Seconds]], _roundResult_.[[Milliseconds]], _roundResult_.[[Microseconds]], _roundResult_.[[Nanoseconds]], _largestUnit_). 1. Return ? CreateTemporalDuration(_roundResult_.[[Years]], _roundResult_.[[Months]], _roundResult_.[[Weeks]], _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]). @@ -536,11 +532,7 @@

Temporal.PlainDateTime.prototype.since ( _other_ [ , _options_ ] )

1. Let _dateTime_ be the *this* value. 1. Perform ? RequireInternalSlot(_dateTime_, [[InitializedTemporalDateTime]]). 1. Set _other_ to ? ToTemporalDateTime(_other_). - 1. Let _calendar_ be _temporalDate_.[[Calendar]]. - 1. Let _calendarID_ be ? CalendarToString(_calendar_). - 1. Let _otherCalendar_ be _other_.[[Calendar]]. - 1. Let _otherCalendarID_ be ? CalendarToString(_otherCalendar_). - 1. If _calendarID_ ≠ _otherCalendarID_, throw a *RangeError* exception. + 1. If ? CalendarEquals(_dateTime_.[[Calendar]], _other_.[[Calendar]]) is *false*, throw a *RangeError* exception. 1. Set _options_ to ? NormalizeOptionsObject(_options_). 1. Let _smallestUnit_ be ? ToSmallestTemporalDurationUnit(_options_, « », *"nanoseconds"*). 1. Let _defaultLargestUnit_ be ! LargerOfTwoTemporalDurationUnits(*"days"*, _smallestUnit_). @@ -550,7 +542,7 @@

Temporal.PlainDateTime.prototype.since ( _other_ [ , _options_ ] )

1. Set _roundingMode_ to ! NegateTemporalRoundingMode(_roundingMode_). 1. Let _maximum_ be ! MaximumTemporalDurationRoundingIncrement(_smallestUnit_). 1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, _maximum_, *false*). - 1. Let _diff_ be ? DifferenceDateTime(_other_.[[ISOYear]], _other_.[[ISOMonth]], _other_.[[ISODay]], _other_.[[ISOHour]], _other_.[[ISOMinute]], _other_.[[ISOSecond]], _other_.[[ISOMillisecond]], _other_.[[ISOMicrosecond]], _other_.[[ISONanosecond]], _dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _calendar_, _largestUnit_). + 1. Let _diff_ be ? DifferenceDateTime(_other_.[[ISOYear]], _other_.[[ISOMonth]], _other_.[[ISODay]], _other_.[[ISOHour]], _other_.[[ISOMinute]], _other_.[[ISOSecond]], _other_.[[ISOMillisecond]], _other_.[[ISOMicrosecond]], _other_.[[ISONanosecond]], _dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _dateTime_.[[Calendar]], _largestUnit_). 1. Let _roundResult_ be ? RoundDuration(−_diff_.[[Years]], −_diff_.[[Months]], −_diff_.[[Weeks]], −_diff_.[[Days]], −_diff_.[[Hours]], −_diff_.[[Minutes]], −_diff_.[[Seconds]], −_diff_.[[Milliseconds]], −_diff_.[[Microseconds]], −_diff_.[[Nanoseconds]], _roundingIncrement_, _smallestUnit_, _roundingMode_, _dateTime_). 1. Let _result_ be ! BalanceDuration(−_roundResult_.[[Days]], −_roundResult_.[[Hours]], −_roundResult_.[[Minutes]], −_roundResult_.[[Seconds]], −_roundResult_.[[Milliseconds]], −_roundResult_.[[Microseconds]], −_roundResult_.[[Nanoseconds]], _largestUnit_). 1. Return ? CreateTemporalDuration(−_roundResult_.[[Years]], −_roundResult_.[[Months]], −_roundResult_.[[Weeks]], _result_.[[Days]], _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]). @@ -1146,7 +1138,7 @@

TemporalDateTimeToString ( _isoYear_, _isoMonth_, _isoDay_, _hour_, _minute_ 1. Let _hour_ be _hour_ formatted as a two-digit decimal number, padded to the left with a zero if necessary. 1. Let _minute_ be _minute_ formatted as a two-digit decimal number, padded to the left with a zero if necessary. 1. Let _seconds_ be ! FormatSecondsStringPart(_second_, _millisecond_, _microsecond_, _nanosecond_, _precision_). - 1. Let _calendarID_ be ? CalendarToString(_calendar_). + 1. Let _calendarID_ be ? ToString(_calendar_). 1. Let _calendarString_ be ? FormatCalendarAnnotation(_calendarID_, _showCalendar_). 1. Return the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), _month_, the code unit 0x002D (HYPHEN-MINUS), _day_, 0x0054 (LATIN CAPITAL LETTER T), _hour_, the code unit 0x003A (COLON), _minute_, _seconds_, and _calendarString_. diff --git a/spec/plainmonthday.html b/spec/plainmonthday.html index 753d0c2798..4000df0ab0 100644 --- a/spec/plainmonthday.html +++ b/spec/plainmonthday.html @@ -527,7 +527,7 @@

TemporalMonthDayToString ( _monthDay_, _showCalendar_ )

1. Let _month_ be _monthDay_.[[ISOMonth]] formatted as a two-digit decimal number, padded to the left with a zero if necessary. 1. Let _day_ be _monthDay_.[[ISODay]] formatted as a two-digit decimal number, padded to the left with a zero if necessary. 1. Let _result_ be the string-concatenation of _month_, the code unit 0x002D (HYPHEN-MINUS), and _day_. - 1. Let _calendarID_ be ? CalendarToString(_monthDay_.[[Calendar]]). + 1. Let _calendarID_ be ? ToString(_monthDay_.[[Calendar]]). 1. If _calendarID_ is not *"iso8601"*, then 1. Let _year_ be ! PadYear(_monthDay_.[[ISOYear]]). 1. Set _result_ to the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), and _result_. diff --git a/spec/plaintime.html b/spec/plaintime.html index 7b90bb8413..e10e24dd02 100644 --- a/spec/plaintime.html +++ b/spec/plaintime.html @@ -650,7 +650,7 @@

ToTemporalTime ( _item_ [ , _constructor_ [ , _overflow_ ] ] )

1. Let _calendar_ be ? Get(_item_, *"calendar"*). 1. If _calendar_ is not *undefined*, then 1. Set _calendar_ to ? ToTemporalCalendar(_calendar_). - 1. If ? CalendarToString(_calendar_) is not *"iso8601"*, then + 1. If ? ToString(_calendar_) is not *"iso8601"*, then 1. Throw a *RangeError* exception. 1. Let _result_ be ? ToTemporalTimeRecord(_item_). 1. Set _result_ to ? RegulateTime(_result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]], _overflow_). diff --git a/spec/plainyearmonth.html b/spec/plainyearmonth.html index 6b2313c422..65fa3b1a16 100644 --- a/spec/plainyearmonth.html +++ b/spec/plainyearmonth.html @@ -325,10 +325,7 @@

Temporal.PlainYearMonth.prototype.until ( _other_ [ , _options_ ] )

1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]). 1. Set _other_ to ? ToTemporalYearMonth(_other_). 1. Let _calendar_ be _yearMonth_.[[Calendar]]. - 1. Let _calendarID_ be ? CalendarToString(_calendar_). - 1. Let _otherCalendar_ be _other_.[[Calendar]]. - 1. Let _otherCalendarID_ be ? CalendarToString(_otherCalendar_). - 1. If _calendarID_ ≠ _otherCalendarID_, throw a *RangeError* exception. + 1. If ? CalendarEquals(_calendar_, _other_.[[Calendar]]) is *false*, throw a *RangeError* exception. 1. Set _options_ to ? NormalizeOptionsObject(_options_). 1. Let _disallowedUnits_ be « *"weeks"*, *"days"*, *"hours"*, *"minutes"*, *"seconds"*, *"milliseconds"*, *"microseconds"*, *"nanoseconds"* ». 1. Let _smallestUnit_ be ? ToSmallestTemporalDurationUnit(_options_, *"months"*, _disallowedUnits_). @@ -336,7 +333,6 @@

Temporal.PlainYearMonth.prototype.until ( _other_ [ , _options_ ] )

1. Perform ? ValidateTemporalUnitRange(_largestUnit_, _smallestUnit_). 1. Let _roundingMode_ be ? ToTemporalRoundingMode(_options_, *"trunc"*). 1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, *undefined*, *false*). - 1. Let _calendar_ be _yearMonth_.[[Calendar]]. 1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"year"* »). 1. Let _otherFields_ be ToTemporalYearMonthFields(_other_, _fieldNames_). 1. Perform ! CreateDataPropertyOrThrow(_otherFields_, *"day"*, *1*𝔽). @@ -364,10 +360,7 @@

Temporal.PlainYearMonth.prototype.since ( _other_ [ , _options_ ] )

1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]). 1. Set _other_ to ? ToTemporalYearMonth(_other_). 1. Let _calendar_ be _yearMonth_.[[Calendar]]. - 1. Let _calendarID_ be ? CalendarToString(_calendar_). - 1. Let _otherCalendar_ be _other_.[[Calendar]]. - 1. Let _otherCalendarID_ be ? CalendarToString(_otherCalendar_). - 1. If _calendarID_ ≠ _otherCalendarID_, throw a *RangeError* exception. + 1. If ? CalendarEquals(_calendar_, _other_.[[Calendar]]) is *false*, throw a *RangeError* exception. 1. Set _options_ to ? NormalizeOptionsObject(_options_). 1. Let _disallowedUnits_ be « *"weeks"*, *"days"*, *"hours"*, *"minutes"*, *"seconds"*, *"milliseconds"*, *"microseconds"*, *"nanoseconds"* ». 1. Let _smallestUnit_ be ? ToSmallestTemporalDurationUnit(_options_, *"months"*, _disallowedUnits_). @@ -376,7 +369,6 @@

Temporal.PlainYearMonth.prototype.since ( _other_ [ , _options_ ] )

1. Let _roundingMode_ be ? ToTemporalRoundingMode(_options_, *"trunc"*). 1. Set _roundingMode_ to ! NegateTemporalRoundingMode(_roundingMode_). 1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, *undefined*, *false*). - 1. Let _calendar_ be _yearMonth_.[[Calendar]]. 1. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"year"* »). 1. Let _otherFields_ be ToTemporalYearMonthFields(_other_, _fieldNames_). 1. Perform ! CreateDataPropertyOrThrow(_otherFields_, *"day"*, *1*𝔽). @@ -760,7 +752,7 @@

TemporalYearMonthToString ( _yearMonth_, _showCalendar_ )

1. Let _year_ be ! PadYear(_yearMonth_.[[ISOYear]]). 1. Let _month_ be _yearMonth_.[[ISOMonth]] formatted as a two-digit decimal number, padded to the left with a zero if necessary. 1. Let _result_ be the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), and _month_. - 1. Let _calendarID_ be ? CalendarToString(_yearMonth_.[[Calendar]]). + 1. Let _calendarID_ be ? ToString(_yearMonth_.[[Calendar]]). 1. If _calendarID_ is not *"iso8601"*, then 1. Let _day_ be _yearMonth_.[[ISODay]] formatted as a two-digit decimal number, padded to the left with a zero if necessary. 1. 1. Set _result_ to the string-concatenation of _result_, the code unit 0x002D (HYPHEN-MINUS), and _day_. diff --git a/spec/zoneddatetime.html b/spec/zoneddatetime.html index 468ed18ee6..8238dad52d 100644 --- a/spec/zoneddatetime.html +++ b/spec/zoneddatetime.html @@ -1360,7 +1360,7 @@

TemporalZonedDateTimeToString ( _zonedDateTime_, _precision_, _showCalendar_ 1. Let _timeZoneString_ be the empty String. 1. Else, 1. Let _timeZoneString_ be ? TimeZoneToString(_timeZone_). - 1. Let _calendarID_ be ? CalendarToString(_zonedDateTime_.[[Calendar]]). + 1. Let _calendarID_ be ? ToString(_zonedDateTime_.[[Calendar]]). 1. Let _calendarString_ be ? FormatCalendarAnnotation(_calendarID_, _showCalendar_). 1. Return the string-concatenation of _dateTimeString_, _offsetString_, the code unit 0x005B (LEFT SQUARE BRACKET), _timeZoneString_, the code unit 0x005D (RIGHT SQUARE BRACKET), and _calendarString_.