Skip to content

Commit 0b6d24b

Browse files
committed
ParseMonthCode, CreateMonthCode
1 parent 4c2f718 commit 0b6d24b

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

spec.emu

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -919,42 +919,51 @@ contributors: Google, Ecma International
919919
</emu-alg>
920920
</emu-clause>
921921

922-
<emu-clause id="sup-temporal-integerfrommonthcode" type="implementation-defined abstract operation">
922+
<emu-clause id="sup-temporal-parsemonthcode" type="implementation-defined abstract operation">
923923
<h1>
924-
IntegerFromMonthCode (
924+
ParseMonthCode (
925925
_monthCode_: a String,
926-
): an integer
926+
): an Record with fields [[Number]] (an integer) and [[IsLeap]] (a boolean)
927927
</h1>
928928
<dl class="header">
929929
<dt>description</dt>
930930
<dd>
931-
It returns the integer number contained in _monthCode_.
931+
It parses a valid month code string (such as one returned by ToMonthCode or CreateMonthCode) into its parts.
932932
</dd>
933933
</dl>
934934
<p>It performs the following steps when called:</p>
935935
<emu-alg>
936-
1. Assert: The length of _monthCode_ is 3 or 4.
936+
1. If the length of _monthCode_ is 3, then
937+
1. Let _isLeap_ be *false*.
938+
1. Else,
939+
1. Assert: the length of _monthCode_ is 4.
940+
1. Let _isLeap_ be *true*.
937941
1. Let _monthCodeDigits_ be the substring of _monthCode_ from 1 to 3.
938-
1. Return ℝ(StringToNumber(_monthCodeDigits_)).
942+
1. Let _number_ be ℝ(StringToNumber(_monthCodeDigits_)).
943+
1. Return the Record { [[Number]]: _number_, [[IsLeap]]: _isLeap_ }.
939944
</emu-alg>
940945
</emu-clause>
941946

942-
<emu-clause id="sup-temporal-monthcodefrominteger" type="implementation-defined abstract operation">
947+
<emu-clause id="sup-temporal-createmonthcode" type="implementation-defined abstract operation">
943948
<h1>
944-
MonthCodeFromInteger (
945-
_integer_: an integer,
949+
CreateMonthCode (
950+
_number_: an integer,
951+
_isLeap_: a Boolean,
946952
): a String
947953
</h1>
948954
<dl class="header">
949955
<dt>description</dt>
950956
<dd>
951-
It returns a month code for a non-leap month containing the given integer number.
957+
It creates a month code with the given month number and leap month flag.
952958
</dd>
953959
</dl>
954960
<p>It performs the following steps when called:</p>
955961
<emu-alg>
956962
1. Let _numberPart_ be ToZeroPaddedDecimalString(_integer_, 2).
957-
1. Return the string-concatenation of the code unit 0x004D (LATIN CAPITAL LETTER M) and _numberPart_.
963+
1. If _isLeap_ is *true*, then
964+
1. Return the string-concatenation of the code unit 0x004D (LATIN CAPITAL LETTER M), _numberPart_, and the code unit 0x004C (LATIN CAPITAL LETTER L).
965+
1. Else,
966+
1. Return the string-concatenation of the code unit 0x004D (LATIN CAPITAL LETTER M) and _numberPart_.
958967
</emu-alg>
959968
</emu-clause>
960969

@@ -1061,7 +1070,7 @@ contributors: Google, Ecma International
10611070
1. If _calendar_ is *"chinese"*, *"dangi"*, or *"hebrew"*, then
10621071
1. If _calendar_ is *"chinese"* or *"dangi"*, then
10631072
1. If IsValidMonthCodeForCalendarInYear(_calendar_, _y2_, _monthCode_) is *false*, then
1064-
1. Set _monthCode_ to MonthCodeFromInteger(IntegerFromMonthCode(_monthCode_)).
1073+
1. Set _monthCode_ to CreateMonthCode(ParseMonthCode(_monthCode_).[[Number]], *false*).
10651074
1. Else,
10661075
1. Assert: _calendar_ is *"hebrew"*.
10671076
1. Let _d2_ be CalendarISOToDate(_calendar_, ! CalendarDateCodesToISO(_calendar_, _y2_, *"M01"*, 1)).
@@ -1074,7 +1083,7 @@ contributors: Google, Ecma International
10741083
1. Assert: IsValidMonthCodeForCalendarInYear(_calendar_, _y2_, _monthCode_) is *true*.
10751084
1. Let _month_ be CalendarISOToDate(_calendar_, ! CalendarDateCodesToISO(_calendar_, _y2_, _monthCode_, 1)).[[Month]].
10761085
1. Else,
1077-
1. Let _month_ be IntegerFromMonthCode(_monthCode_).
1086+
1. Let _month_ be ParseMonthCode(_monthCode_).[[Number]].
10781087
1. Return the Record { [[Year]]: _y2_, [[Month]]: _month_ }.
10791088
</emu-alg>
10801089
</emu-clause>

0 commit comments

Comments
 (0)