You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_calendar_: a calendar type that is not *"iso8601"*,
599
+
_arithmeticYear_: an integer,
600
+
_monthCode_: a month code,
601
+
_overflow_: ~constrain~ or ~reject~,
602
+
): either a normal completion containing a month code or a throw completion
603
+
</h1>
604
+
<dl class="header">
605
+
<dt>description</dt>
606
+
<dd>
607
+
It returns the month code in _arithmeticYear_ of _calendar_ that best matches the given _monthCode_. If _monthCode_ does not exist in _arithmeticYear_, it is constrained to the best common month if _overflow_ is ~constrain~, or an error is thrown if _overflow_ is ~reject~.
608
+
</dd>
609
+
</dl>
610
+
<p>It performs the following steps when called:</p>
611
+
<emu-alg>
612
+
1. Assert: IsValidMonthCodeForCalendar(_calendar_, _monthCode_) is *true*.
613
+
1. If YearContainsMonthCode(_calendar_, _arithmeticYear_, _monthCode_) is *true*, return _monthCode_.
614
+
1. If _overflow_ is ~reject~, throw a *RangeError* exception.
615
+
1. Assert: _calendar_ is listed in the Calendar column of <emu-xref href="#table-additional-month-codes"></emu-xref>.
616
+
1. Let _r_ be the row in <emu-xref href="#table-additional-month-codes"></emu-xref> which the _calendar_ is in the Calendar column.
617
+
1. Let _shiftType_ be the value given in the *"Leap to Common Month Transformation"* column of _r_.
@@ -903,10 +1002,11 @@ contributors: Google, Ecma International
903
1002
<p>It performs the following steps when called:</p>
904
1003
<emu-alg>
905
1004
1. Let _calendarDate_ be CalendarISOToDate(_calendar_, _isoDate_).
906
-
1. Add _duration_.[[Years]] to _calendarDate_.
907
-
1. (This step only matters for lunisolar calendars.) If _calendarDate_.[[MonthCode]] is a leap month that doesn't exist in the year, then:
908
-
1. Set _calendarDate_ to another date according to the cultural conventions of that calendar's users. Of the currently supported calendars: if _calendar_ is *"chinese"* or *"dangi"*, change _calendarDate_.[[MonthCode]] to the same month code but without the *"L"*. If _calendar_ is *"hebrew"*, change _calendarDate_.[[MonthCode]] from *"M05L"* to *"M06"*.
909
-
1. Update _calendarDate_.[[Month]] accordingly.
1005
+
1. Add _duration_.[[Years]] to _calendarDate_ without changing any less-significant fields.
1006
+
1. If YearContainsMonthCode(_calendar_, _calendarDate_.[[Year]], _calendarDate_.[[MonthCode]]) is *false*, then
1007
+
1. NOTE: This only happens in lunisolar calendars.
1008
+
1. Set _calendarDate_.[[MonthCode]] to ! ConstrainMonthCode(_calendar_, _calendarDate_.[[Year]], _calendarDate_.[[MonthCode]], ~constrain~).
1009
+
1. Set _calendarDate_.[[Month]] to MonthCodeToOrdinal(_calendar_, _calendarDate_.[[Year]], _calendarDate_.[[MonthCode]]).
910
1010
1. Add _duration_.[[Months]] to _calendarDate_, balancing _calendarDate_ if it goes over a year boundary.
911
1011
1. If the date described by _calendarDate_ does not exist, then
912
1012
1. If _overflow_ is ~reject~, throw a *RangeError* exception.
@@ -972,16 +1072,23 @@ contributors: Google, Ecma International
972
1072
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal-nonisocalendardatetoiso"></emu-xref>.</p>
973
1073
<p>It performs the following steps when called:</p>
974
1074
<emu-alg>
975
-
1. If _fields_.[[Era]] and _fields_.[[EraYear]] are not ~unset~ and IsValidEraYearForCalendar(_calendar_, _fields_.[[Era]], _fields_.[[EraYear]]) is *false*, throw a *RangeError* exception.
976
-
1. If _fields_.[[MonthCode]] is not ~unset~ and IsValidMonthCodeForCalendar(_calendar_, _fields_.[[MonthCode]]) is *false*, throw a *RangeError* exception.
977
-
1. If _fields_ describes an existing date in _calendar_, return an implementation-defined ISO Date Record that corresponds to the date described by _fields_.
978
-
1. If _overflow_ is ~reject~, throw a *RangeError* exception.
979
-
1. (This step only matters for lunisolar calendars.) If _fields_.[[MonthCode]] is a leap month that doesn't exist in the year, then:
980
-
1. Set _fields_ to another date according to the cultural conventions of that calendar's users. Of the currently supported calendars: if _calendar_ is *"chinese"* or *"dangi"*, change _fields_.[[MonthCode]] to the same month code but without the *"L"*. If _calendar_ is *"hebrew"*, change _fields_.[[MonthCode]] from *"M05L"* to *"M06"*.
981
-
1. Update _fields_.[[Month]] accordingly.
982
-
1. If _fields_.[[MonthCode]] is a valid month code for _fields_.[[Year]], but the date described by _fields_ does not exist, set _fields_.[[Day]] to the closest day in the same month. If there are two equally-close dates in the same month, pick the later one.
983
-
1. (This step does not apply to any currently supported calendars.) If the date described by _fields_ still does not exist, set _fields_ to the closest date in the same year. If there are two equally-close dates in that year, pick the later one.
984
-
1. Return an implementation-defined ISO Date Record that corresponds to the date described by _fields_.
1075
+
1. If _fields_.[[Era]] and _fields_.[[EraYear]] are not ~unset~, then
1076
+
1. If IsValidEraYearForCalendar(_calendar_, _fields_.[[Era]], _fields_.[[EraYear]]) is *false*, throw a *RangeError* exception.
1077
+
1. Let _arithmeticYear_ be CalendarDateArithmeticYearForEraYear(_calendar_, _fields_.[[Era]], _fields_.[[EraYear]]).
1078
+
1. Else,
1079
+
1. Assert: _fields_.[[Year]] is not ~unset~.
1080
+
1. Let _arithmeticYear_ be _fields_.[[Year]].
1081
+
1. If _fields_.[[MonthCode]] is not ~unset~, then
1082
+
1. If IsValidMonthCodeForCalendar(_calendar_, _fields_.[[MonthCode]]) is *false*, throw a *RangeError* exception.
1083
+
1. Let _constrainedMonthCode_ be ? ConstrainMonthCode(_calendar_, _arithmeticYear_, _fields_.[[MonthCode]], _overflow_).
1084
+
1. Let _ordinalMonth_ be MonthCodeToOrdinal(_calendar_, _arithmeticYear_, _constrainedMonthCode_).
1085
+
1. Else,
1086
+
1. Assert: _fields_.[[Month]] is not ~unset~.
1087
+
1. Let _ordinalMonth_ be _fields_.[[Month]].
1088
+
1. Let _day_ be _fields_.[[Day]].
1089
+
1. Assert: _day_ is not ~unset~.
1090
+
1. If the date described by _calendar_, _arithmeticYear_, _ordinalMonth_, and _day_ does not exist, set _day_ to the closest day in the same month. If there are two equally-close dates in the same month, pick the later one.
1091
+
1. Return an implementation-defined ISO Date Record that corresponds to the date described by _calendar_, _arithmeticYear_, _ordinalMonth_, and _day_.
0 commit comments