@@ -43,6 +43,59 @@ <h1>AvailableCalendars ( ): a List of calendar types</h1>
43
43
</emu-clause >
44
44
</emu-clause >
45
45
46
+ <emu-clause id =" sec-temporal-month-codes" >
47
+ <h1 >Month Codes</h1 >
48
+
49
+ <emu-clause id =" sec-temporal-parsemonthcode" type =" abstract operation" >
50
+ <h1 >
51
+ ParseMonthCode (
52
+ _monthCode_ : a String,
53
+ ): a Record with fields [[MonthNumber]] (an integer) and [[IsLeapMonth]] (a Boolean)
54
+ </h1 >
55
+ <dl class =" header" >
56
+ <dt >description</dt >
57
+ <dd >
58
+ It parses a valid month code string (such as one returned by ToMonthCode or CreateMonthCode) into its parts.
59
+ </dd >
60
+ </dl >
61
+ <p >It performs the following steps when called:</p >
62
+ <emu-alg >
63
+ 1. If the length of _monthCode_ is 3, then
64
+ 1. Let _isLeapMonth_ be *false* .
65
+ 1. Else,
66
+ 1. Assert: The length of _monthCode_ is 4.
67
+ 1. Let _isLeapMonth_ be *true* .
68
+ 1. Let _monthCodeDigits_ be the substring of _monthCode_ from 1 to 3.
69
+ 1. Let _monthNumber_ be ℝ(StringToNumber(_monthCodeDigits_ )).
70
+ 1. Return the Record { [[MonthNumber]]: _monthNumber_ , [[IsLeapMonth]]: _isLeapMonth_ }.
71
+ </emu-alg >
72
+ </emu-clause >
73
+
74
+ <emu-clause id =" sec-temporal-createmonthcode" type =" abstract operation" >
75
+ <h1 >
76
+ CreateMonthCode (
77
+ _monthNumber_ : an integer in the inclusive interval from 0 to 99,
78
+ _isLeapMonth_ : a Boolean,
79
+ ): a String
80
+ </h1 >
81
+ <dl class =" header" >
82
+ <dt >description</dt >
83
+ <dd >
84
+ It creates a month code with the given month number and leap month flag.
85
+ </dd >
86
+ </dl >
87
+ <p >It performs the following steps when called:</p >
88
+ <emu-alg >
89
+ 1. Assert: If _isLeapMonth_ is *false* , _monthNumber_ > 0.
90
+ 1. Let _numberPart_ be ToZeroPaddedDecimalString(_monthNumber_ , 2).
91
+ 1. If _isLeapMonth_ is *true* , then
92
+ 1. Return the string-concatenation of the code unit 0x004D (LATIN CAPITAL LETTER M), _numberPart_ , and the code unit 0x004C (LATIN CAPITAL LETTER L).
93
+ 1. Else,
94
+ 1. Return the string-concatenation of the code unit 0x004D (LATIN CAPITAL LETTER M) and _numberPart_ .
95
+ </emu-alg >
96
+ </emu-clause >
97
+ </emu-clause >
98
+
46
99
<emu-clause id =" sec-temporal-calendar-abstract-ops" >
47
100
<h1 >Abstract Operations</h1 >
48
101
@@ -973,15 +1026,13 @@ <h1>
973
1026
</dl >
974
1027
<emu-alg >
975
1028
1. If _calendar_ is *"iso8601"* , then
976
- 1. Let _monthNumberPart_ be ToZeroPaddedDecimalString(_isoDate_ .[[Month]], 2).
977
- 1. Let _monthCode_ be the string-concatenation of *"M"* and _monthNumberPart_ .
978
1029
1. If MathematicalInLeapYear(EpochTimeForYear(_isoDate_ .[[Year]])) = 1, let _inLeapYear_ be *true* ; else let _inLeapYear_ be *false* .
979
1030
1. Return Calendar Date Record {
980
1031
[[Era]]: *undefined* ,
981
1032
[[EraYear]]: *undefined* ,
982
1033
[[Year]]: _isoDate_ .[[Year]],
983
1034
[[Month]]: _isoDate_ .[[Month]],
984
- [[MonthCode]]: _monthCode_ ,
1035
+ [[MonthCode]]: CreateMonthCode( _isoDate_ .[[Month]], *false* ) ,
985
1036
[[Day]]: _isoDate_ .[[Day]],
986
1037
[[DayOfWeek]]: ISODayOfWeek(_isoDate_ ),
987
1038
[[DayOfYear]]: ISODayOfYear(_isoDate_ ),
@@ -1173,15 +1224,12 @@ <h1>
1173
1224
1. If _monthCode_ is ~unset~ , then
1174
1225
1. If _month_ is ~unset~ , throw a *TypeError* exception.
1175
1226
1. Return ~unused~ .
1176
- 1. Assert: _monthCode_ is a String.
1177
- 1. NOTE: The ISO 8601 calendar does not include leap months.
1178
- 1. If the length of _monthCode_ is not 3, throw a *RangeError* exception.
1179
- 1. If the first code unit of _monthCode_ is not 0x004D (LATIN CAPITAL LETTER M), throw a *RangeError* exception.
1180
- 1. Let _monthCodeDigits_ be the substring of _monthCode_ from 1.
1181
- 1. If ParseText(StringToCodePoints(_monthCodeDigits_ ), | DateMonth | ) is a List of errors, throw a *RangeError* exception.
1182
- 1. Let _monthCodeInteger_ be ℝ(StringToNumber(_monthCodeDigits_ )).
1183
- 1. If _month_ is not ~unset~ and _month_ ≠ _monthCodeInteger_ , throw a *RangeError* exception.
1184
- 1. Set _fields_ .[[Month]] to _monthCodeInteger_ .
1227
+ 1. Perform ? ToMonthCode(_monthCode_ ).
1228
+ 1. Let _parsedMonthCode_ be ParseMonthCode(_monthCode_ ).
1229
+ 1. If _parsedMonthCode_ .[[IsLeapMonth]] is *true* , throw a *RangeError* exception.
1230
+ 1. If _parsedMonthCode_ .[[MonthNumber]] > 12, throw a *RangeError* exception.
1231
+ 1. If _month_ is not ~unset~ and _month_ ≠ _parsedMonthCode_ .[[MonthNumber]], throw a *RangeError* exception.
1232
+ 1. Set _fields_ .[[Month]] to _parsedMonthCode_ .[[MonthNumber]].
1185
1233
1. Else,
1186
1234
1. Perform ? NonISOResolveFields(_calendar_ , _fields_ , _type_ ).
1187
1235
1. Return ~unused~ .
0 commit comments