Skip to content

Commit bd041c3

Browse files
committed
Editorial: Move ISOMonthDayFromFields into CalendarMonthDayFromFields
This is the only place it's called from. This refactor is part of consolidating the many calendar AOs. See: #2948
1 parent df52443 commit bd041c3

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

polyfill/lib/calendar.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl['iso8601'] = {
153153
requireFields(fields, ['day']);
154154
const referenceISOYear = 1972;
155155
let { month, day, year } = resolveNonLunisolarMonth(fields);
156-
({ month, day } = ES.RegulateISODate(year !== undefined ? year : referenceISOYear, month, day, overflow));
156+
({ month, day } = ES.RegulateISODate(year ?? referenceISOYear, month, day, overflow));
157157
return { month, day, year: referenceISOYear };
158158
},
159159
extraFields() {

spec/calendar.html

+9-30
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,15 @@ <h1>
886886
1. If _calendar_ is *"iso8601"*, then
887887
1. If _fields_.[[Day]] is ~unset~, throw a *TypeError* exception.
888888
1. Perform ? ISOResolveMonth(_fields_).
889-
1. Return ? ISOMonthDayFromFields(_fields_, _overflow_).
889+
1. Assert: _fields_.[[Month]] is not ~unset~.
890+
1. Let _referenceISOYear_ be 1972 (the first ISO 8601 leap year after the epoch).
891+
1. If _fields_.[[Year]] is ~unset~, let _year_ be _referenceISOYear_; else let _year_ be _fields_.[[Year]].
892+
1. Let _result_ be ? RegulateISODate(_year_, _fields_.[[Month]], _fields_.[[Day]], _overflow_).
893+
1. Return ISO Date Record {
894+
[[Year]]: _referenceISOYear_,
895+
[[Month]]: _result_.[[Month]],
896+
[[Day]]: _result_.[[Day]]
897+
}.
890898
1. Perform ? CalendarResolveFields(_calendar_, _fields_, ~month-day~).
891899
1. Return ? CalendarMonthDayToISOReferenceDate(_calendar_, _fields_, _overflow_).
892900
</emu-alg>
@@ -1042,35 +1050,6 @@ <h1>
10421050
</emu-alg>
10431051
</emu-clause>
10441052

1045-
<emu-clause id="sec-temporal-isomonthdayfromfields" type="abstract operation">
1046-
<h1>
1047-
ISOMonthDayFromFields (
1048-
_fields_: a Calendar Fields Record,
1049-
_overflow_: ~constrain~ or ~reject~,
1050-
): either a normal completion containing an ISO Date Record or a throw completion
1051-
</h1>
1052-
<dl class="header">
1053-
<dt>description</dt>
1054-
<dd>It performs the conversion operation of a Calendar Fields Record to an ISO Date Record for the ISO 8601 calendar in the context of Temporal.PlainMonthDay, as CalendarMonthDayFromFields does for other calendars.</dd>
1055-
</dl>
1056-
<emu-alg>
1057-
1. Let _month_ be _fields_.[[Month]].
1058-
1. Let _day_ be _fields_.[[Day]].
1059-
1. Assert: _month_ and _day_ are not ~unset~.
1060-
1. Let _year_ be _fields_.[[Year]].
1061-
1. Let _referenceISOYear_ be 1972 (the first ISO 8601 leap year after the epoch).
1062-
1. If _year_ is ~unset~, then
1063-
1. Let _result_ be ? RegulateISODate(_referenceISOYear_, _month_, _day_, _overflow_).
1064-
1. Else,
1065-
1. Let _result_ be ? RegulateISODate(_year_, _month_, _day_, _overflow_).
1066-
1. Return ISO Date Record {
1067-
[[Year]]: _referenceISOYear_,
1068-
[[Month]]: _result_.[[Month]],
1069-
[[Day]]: _result_.[[Day]]
1070-
}.
1071-
</emu-alg>
1072-
</emu-clause>
1073-
10741053
<emu-clause id="sec-temporal-isofieldkeystoignore" type="abstract operation">
10751054
<h1>
10761055
ISOFieldKeysToIgnore (

0 commit comments

Comments
 (0)