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
Editorial: Include ISO 8601 algorithm in CalendarDateToISO
Move the ISO 8601 code from CalendarDateFromFields and
CalendarYearMonthFromFields into CalendarDateToISO. At this point it just
consists of RegulateISODate anyway.
To achieve this, we also drop the requirement that CalendarDateToISO
checks its return value is in the representable range, instead moving that
to CalendarDateFromFields and CalendarYearMonthFromFields since it is
different in both cases.
See: #2948Closes: #2998
1. Let _firstDayIndex_ be the 1-based index of the first day of the month described by _fields_ (i.e., 1 unless the month's first day is skipped by this calendar.)
_calendar_: a calendar type that is not *"iso8601"*,
1113
+
_calendar_: a calendar type,
1120
1114
_fields_: a Calendar Fields Record,
1121
1115
_overflow_: ~constrain~ or ~reject~,
1122
1116
): either a normal completion containing an ISO Date Record or a throw completion
@@ -1129,11 +1123,14 @@ <h1>
1129
1123
For ~constrain~, values that do not form a valid date are clamped to their respective valid range.
1130
1124
</dd>
1131
1125
</dl>
1132
-
<p>
1133
-
Like RegulateISODate, the operation throws a *RangeError* exception when _overflow_ is ~reject~ and the date described by _fields_ does not exist.
1134
-
It also throws a *RangeError* exception if the date described by _fields_ is outside the range allowed by ISODateWithinLimits.
1135
-
</p>
1136
-
<p>Clamping an invalid date to the correct range when _overflow_ is ~constrain~ is a behaviour specific to each built-in calendar, but all built-in calendars follow this guideline:</p>
1126
+
<emu-alg>
1127
+
1. If _calendar_ is *"iso8601"*, then
1128
+
1.Assert:_fields_.[[Year]], _fields_.[[Month]], and _fields_.[[Day]] are not ~unset~.
1. Return an implementation-defined ISO Date Record, or throw a *RangeError* exception, as described below.
1131
+
</emu-alg>
1132
+
<p>Like RegulateISODate, the operation throws a *RangeError* exception when _overflow_ is ~reject~ and the date described by _fields_ does not exist.</p>
1133
+
<p>Clamping an invalid date to the correct range when _overflow_ is ~constrain~ is a behaviour specific to each calendar other than *"iso8601"*, but all calendars follow this guideline:</p>
1137
1134
<ul>
1138
1135
<li>Pick the closest day in the same month. If there are two equally-close dates in that month, pick the later one.</li>
1139
1136
<li>If the month is a leap month that doesn't exist in the year, pick another date according to the cultural conventions of that calendar's users. Usually this will result in the same day in the month before or after where that month would normally fall in a leap year.</li>
0 commit comments