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"*,
577
+
_year_: an integer,
578
+
_monthCode_: a String,
579
+
_overflow_: ~constrain~ or ~reject~,
580
+
): either a normal completion containing an integer or a throw completion
581
+
</h1>
582
+
<dl class="header">
583
+
<dt>description</dt>
584
+
<dd>
585
+
It returns the arithmetical month in _year_ that best matches the given _monthCode_ in _calendar_. If _monthCode_ does not exist in _year_, it is constrained to the best common month if _overflow_ is ~constrain~, or an error is thrown if _overflow_ is ~reject~.
586
+
</dd>
587
+
</dl>
588
+
<p>It performs the following steps when called:</p>
589
+
<emu-alg>
590
+
1. Assert: IsValidMonthCodeForCalendar(_calendar_, _monthCode_) is *true*.
591
+
1. Let _monthCodeParts_ be ParseMonthCode(_monthCode_).
592
+
1. If _calendar_ is not listed in the Calendar column of <emu-xref href="#table-additional-month-codes"></emu-xref>, return _monthCodeParts_.[[Number]].
593
+
1. Let _r_ be the row in <emu-xref href="#table-additional-month-codes"></emu-xref> which the _calendar_ is in the Calendar column.
594
+
1. If the *"Leap to Common Month Transformation"* column of _r_ is empty, return _monthCodeParts_.[[Number]].
595
+
1. If YearContainsMonthCode(_calendar_, _year_, _monthCode_) is *false*, then
596
+
1. If _overflow_ is ~reject~, throw a *RangeError* exception.
597
+
1. Let _resolvedMonthCode_ be the result of applying the algorithm described in the *"Leap to Common Month Transformation"* column of _r_ to _monthCode_.
598
+
1. Else,
599
+
1. Let _resolvedMonthCode_ be _monthCode_.
600
+
1. Let _monthsBefore_ be 0.
601
+
1. Let _number_ be 1.
602
+
1. Let _isLeap_ be *false*.
603
+
1. Assert: The *"Additional Month Codes"* column of _r_ does not contain *"M00"* or *"M13"*.
604
+
1. Repeat, while _number_ ≤ 12,
605
+
1. Let _currentMonthCode_ be CreateMonthCode(_number_, _isLeap_).
606
+
1. If YearContainsMonthCode(_calendar_, _year_, _currentMonthCode_), then
607
+
1. Set _monthsBefore_ to _monthsBefore_ + 1.
608
+
1. If _currentMonthCode_ is _resolvedMonthCode_, then
609
+
1. Return _monthsBefore_.
610
+
1. If _isLeap_ is *false*, then
611
+
1. Set _isLeap_ to *true*.
612
+
1. Else,
613
+
1. Set _isLeap_ to *false*.
614
+
1. Set _number_ to _number_ + 1.
615
+
1. Assert: The above loop should have returned before terminating.
_calendar_: a calendar type that is not *"iso8601"*,
937
-
_year_: an integer,
938
-
_monthCode_: a String,
939
-
): an integer or ~invalid~
940
-
</h1>
941
-
<dl class="header">
942
-
<dt>description</dt>
943
-
<dd>
944
-
It interprets _year_ as arithmetical year in the given _calendar_, returning an integer if there is a month with the given _monthCode_ in that year, or ~invalid~ otherwise.
945
-
</dd>
946
-
</dl>
947
-
<p>It performs the following steps when called:</p>
948
-
<emu-alg>
949
-
1. If IsValidMonthCodeForCalendar(_calendar_, _monthCode_) is *false*, then
950
-
1. Return ~invalid~.
951
-
1. Let _monthCodeParts_ be ParseMonthCode(_monthCode_).
952
-
1. If _calendar_ is not *"chinese"*, *"dangi"*, or *"hebrew"*, then
953
-
1. Return _monthCodeParts_.[[Number]].
954
-
1. Let _monthsBefore_ be 0.
955
-
1. Let _number_ be 1.
956
-
1. Let _isLeap_ be *false*.
957
-
1. Repeat, while _number_ ≤ 12,
958
-
1. If _calendar_ contains CreateMonthCode(_number_, _isLeap_) in _year_, according to a calendar-dependent algorithm, then
959
-
1. Set _monthsBefore_ to _monthsBefore_ + 1.
960
-
1. If _monthCodeParts_.[[Number]] is _number_ and _monthCodeParts.[[IsLeap]] is _isLeap_, then
0 commit comments