Skip to content

Commit

Permalink
Make types consistent that Calendar methods are be called with
Browse files Browse the repository at this point in the history
Make sure it is consistent whether a particular Calendar method can be
called with a Temporal.PlainYearMonth or Temporal.PlainMonthDay without
triggering a conversion. (They can all be called with a
Temporal.PlainDate.)

See: #1428
  • Loading branch information
ptomato committed Apr 13, 2021
1 parent 1c09f49 commit c90387b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ <h1>Temporal.Calendar.prototype.monthsInYear ( _dateOrDateTime_ )</h1>
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. Assert: _calendar_.[[Identifier]] is *"iso8601"*.
1. Perform ? ToTemporalDate(_dateOrDateTime_).
1. Perform ? ISOYear(_dateOrDateTime_).
1. Return *12*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>
Expand Down
28 changes: 12 additions & 16 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -1394,12 +1394,11 @@ <h1>Temporal.Calendar.prototype.dayOfWeek ( _dateOrDateTime_ )</h1>
<emu-alg>
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then
1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_).
1. Let _date_ be ? ToTemporalDate(_dateOrDateTime_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Let _dayOfWeek_ be ! ToISODayOfWeek(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]], _dateOrDateTime_.[[ISODay]]).
1. Let _dayOfWeek_ be ! ToISODayOfWeek(_date_.[[ISOYear]], _date_.[[ISOMonth]], _date_.[[ISODay]]).
1. Else,
1. Let _dayOfWeek_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]].
1. Let _dayOfWeek_ be the result of implementation-defined processing of _date_ and the value of _calendar_.[[Identifier]].
1. Return 𝔽(_dayOfWeek_).
</emu-alg>
</emu-clause>
Expand All @@ -1414,12 +1413,11 @@ <h1>Temporal.Calendar.prototype.dayOfYear ( _dateOrDateTime_ )</h1>
<emu-alg>
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then
1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_).
1. Let _date_ be ? ToTemporalDate(_dateOrDateTime_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Let _dayOfYear_ be ! ToISODayOfYear(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]], _dateOrDateTime_.[[ISODay]]).
1. Let _dayOfYear_ be ! ToISODayOfYear(_date_.[[ISOYear]], _date_.[[ISOMonth]], _date_.[[ISODay]]).
1. Else,
1. Let _dayOfYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]].
1. Let _dayOfYear_ be the result of implementation-defined processing of _date_ and the value of _calendar_.[[Identifier]].
1. Return 𝔽(_dayOfYear_).
</emu-alg>
</emu-clause>
Expand All @@ -1434,12 +1432,11 @@ <h1>Temporal.Calendar.prototype.weekOfYear ( _dateOrDateTime_ )</h1>
<emu-alg>
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then
1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_).
1. Let _date_ be ? ToTemporalDate(_dateOrDateTime_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Let _weekOfYear_ be ! ToISOWeekOfYear(_dateOrDateTime_.[[ISOYear]], _dateOrDateTime_.[[ISOMonth]], _dateOrDateTime_.[[ISODay]]).
1. Let _weekOfYear_ be ! ToISOWeekOfYear(_date_.[[ISOYear]], _date_.[[ISOMonth]], _date_.[[ISODay]]).
1. Else,
1. Let _weekOfYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]].
1. Let _weekOfYear_ be the result of implementation-defined processing of _date_ and the value of _calendar_.[[Identifier]].
1. Return 𝔽(_weekOfYear_).
</emu-alg>
</emu-clause>
Expand All @@ -1454,12 +1451,11 @@ <h1>Temporal.Calendar.prototype.daysInWeek ( _dateOrDateTime_ )</h1>
<emu-alg>
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. If Type(_dateOrDateTime_) is not Object or _dateOrDateTime_ does not have an [[ISOYear]] internal slot, then
1. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_).
1. Let _date_ be ? ToTemporalDate(_dateOrDateTime_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Let _daysInWeek_ be 7.
1. Else,
1. Let _daysInWeek_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]].
1. Let _daysInWeek_ be the result of implementation-defined processing of _date_ and the value of _calendar_.[[Identifier]].
1. Return 𝔽(_daysInWeek_).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -1520,7 +1516,7 @@ <h1>Temporal.Calendar.prototype.monthsInYear ( _dateOrDateTime_ )</h1>
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Let _monthsInYear_ be 12.
1. Else,
1. Let _monthsInYear_ be the result of implementation-defined processing of _date_ and the value of _calendar_.[[Identifier]].
1. Let _monthsInYear_ be the result of implementation-defined processing of _dateOrDateTime_ and the value of _calendar_.[[Identifier]].
1. Return 𝔽(_monthsInYear_).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit c90387b

Please sign in to comment.