Skip to content

Commit

Permalink
Normative: Disallow arbitrary integers for the reference ISO year in …
Browse files Browse the repository at this point in the history
…PlainMonthDay

`new Temporal.PlainMonthDay(9, 30, "iso8601", 999_999_999_999_999)` will
now throw an error.

The spec polyfill already implements the same limitation.
  • Loading branch information
anba authored and ptomato committed Jul 21, 2022
1 parent 6f04074 commit 374305c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/plainmonthday.html
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ <h1>CreateTemporalMonthDay ( _isoMonth_, _isoDay_, _calendar_, _referenceISOYear
1. Assert: _isoMonth_, _isoDay_, and _referenceISOYear_ are integers.
1. Assert: Type(_calendar_) is Object.
1. If IsValidISODate(_referenceISOYear_, _isoMonth_, _isoDay_) is *false*, throw a *RangeError* exception.
1. If ISODateTimeWithinLimits(_referenceISOYear_, _isoMonth_, _isoDay_, 12, 0, 0, 0, 0, 0) is *false*, throw a *RangeError* exception.
1. If _newTarget_ is not present, set _newTarget_ to %Temporal.PlainMonthDay%.
1. Let _object_ be ? OrdinaryCreateFromConstructor(_newTarget_, *"%Temporal.PlainMonthDay.prototype%"*, « [[InitializedTemporalMonthDay]], [[ISOMonth]], [[ISODay]], [[ISOYear]], [[Calendar]] »).
1. Set _object_.[[ISOMonth]] to _isoMonth_.
Expand All @@ -393,6 +394,9 @@ <h1>CreateTemporalMonthDay ( _isoMonth_, _isoDay_, _calendar_, _referenceISOYear
1. Set _object_.[[ISOYear]] to _referenceISOYear_.
1. Return _object_.
</emu-alg>
<emu-note>
<p>Deferring to ISODateTimeWithinLimits with an hour of 12 avoids trouble at the extremes of the representable range of dates, which stop just before midnight on each end.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-temporal-temporalmonthdaytostring" aoid="TemporalMonthDayToString">
Expand Down

0 comments on commit 374305c

Please sign in to comment.