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"*,
883
+
_year_: an integer,
884
+
_monthCode_: a String,
885
+
): an Boolean
886
+
</h1>
887
+
<dl class="header">
888
+
<dt>description</dt>
889
+
<dd>
890
+
It interprets _year_ as arithmetical value in the given _calendar_ and returns *true* if there is a month with the given _monthCode_ in that year or *false* otherwise.
891
+
</dd>
892
+
</dl>
893
+
<p>It performs the following steps when called:</p>
894
+
<emu-alg>
895
+
Returns an implementation-and-calendar-defined Boolean as described above.
_calendar_: a calendar type that is not *"iso8601"*,
903
+
_year_: an integer,
904
+
_monthCode_: a String,
905
+
_day_: an integer,
906
+
): either a normal completion containing an ISO Date Record or a throw completion
907
+
</h1>
908
+
<dl class="header">
909
+
<dt>description</dt>
910
+
<dd>
911
+
It returns an ISO Date Record that, when converted to a Calendar Date Record with _calendar_ (for example, with CalendarISOToDate), contains the given _year_, _monthCode_, and _day_ values in its [[Year]], [[MonthCode]], and [[Day]] fields. If this is not possible, a RangeError is thrown.
912
+
</dd>
913
+
</dl>
914
+
<p>It performs the following steps when called:</p>
915
+
<emu-alg>
916
+
Returns an implementation-and-calendar-defined completion as described above.
_calendar_: a calendar type that is not *"iso8601"*,
1004
+
_year_: an integer,
1005
+
_month_: an integer,
1006
+
_day_: an integer,
1007
+
): a Record with fields [[Year]] (an integer), [[Month]] (an integer), and [[Day]] (an integer)
1008
+
</h1>
1009
+
<dl class="header">
1010
+
<dt>description</dt>
1011
+
<dd>
1012
+
It interprets the given _year_ and potentially out-of-range _month_ and _day_ as arithmetical values in the given _calendar_ and returns in-range values by overflowing out-of-range _month_ or _day_ values into the next-highest unit.
1013
+
This date may be outside the range given by ISODateTimeWithinLimits.
1014
+
</dd>
1015
+
</dl>
1016
+
<p>It performs the following steps when called:</p>
1017
+
<emu-alg>
1018
+
1. Let _resolvedYear_ be _year_.
1019
+
1. Let _resolvedMonth_ be _month_.
1020
+
1. Let _monthsInYear_ be CalendarMonthsInYear(_calendar_, _resolvedYear_).
1021
+
1. Repeat, while _resolvedMonth_ ≤ 0,
1022
+
1. Set _resolvedYear_ to _resolvedYear_ - 1.
1023
+
1. Set _monthsInYear_ to CalendarMonthsInYear(_calendar_, _resolvedYear_).
1024
+
1. Set _resolvedMonth_ to _resolvedMonth_ + _monthsInYear_.
1025
+
1. Repeat, while _resolvedMonth_ > _monthsInYear_,
1026
+
1. Set _resolvedMonth_ to _resolvedMonth_ - _monthsInYear_.
1027
+
1. Set _resolvedYear_ to _resolvedYear_ + 1.
1028
+
1. Set _monthsInYear_ to CalendarMonthsInYear(_calendar_, _resolvedYear_).
1029
+
1. Let _resolvedDay_ be _day_.
1030
+
1. Let _daysInMonth_ be CalendarDaysInMonth(_calendar_, _resolvedYear_, _resolvedMonth_).
1031
+
1. Repeat, while _resolvedDay_ ≤ 0,
1032
+
1. Set _resolvedMonth_ to _resolvedMonth_ - 1.
1033
+
1. If _resolvedMonth_ is 0, then
1034
+
1. Set _resolvedYear_ to _resolvedYear_ - 1.
1035
+
1. Set _monthsInYear_ to CalendarMonthsInYear(_calendar_, _resolvedYear_).
1036
+
1. Set _resolvedMonth_ to _monthsInYear_.
1037
+
1. Set _daysInMonth_ to CalendarDaysInMonth(_calendar_, _resolvedYear_, _resolvedMonth_).
1038
+
1. Set _resolvedDay_ to _day_ + _daysInMonth_.
1039
+
1. Repeat, while _resolvedDay_ > _daysInMonth_,
1040
+
1. Set _resolvedDay_ to _resolvedDay_ - _daysInMonth_.
1041
+
1. Set _resolvedMonth_ to _resolvedMonth_ + 1.
1042
+
1. If _resolvedMonth_ > _monthsInYear_, then
1043
+
1. Set _resolvedYear_ to _resolvedYear_ + 1.
1044
+
1. Set _monthsInYear_ to CalendarMonthsInYear(_calendar_, _resolvedYear_).
1045
+
1. Set _resolvedMonth_ to 1.
1046
+
1. Set _daysInMonth_ to CalendarDaysInMonth(_calendar_, _resolvedYear_, _resolvedMonth_).
1047
+
1. Return the Record { [[Year]]: _resolvedYear_, [[Month]]: _resolvedMonth_, [[Day]]: _resolvedDay_ }.
_calendar_: a calendar type that is not *"iso8601"*,
1055
+
_sign_: -1 or 1,
1056
+
_baseDate_: an ISO Date Record,
1057
+
_isoDate2_: an ISO Date Record,
1058
+
_years_: an integer,
1059
+
_months_: an integer,
1060
+
_weeks_: an integer,
1061
+
_days_: an integer,
1062
+
): a Boolean
1063
+
</h1>
1064
+
<dl class="header">
1065
+
<dt>description</dt>
1066
+
<dd>
1067
+
The return value indicates whether the date _date1_, the result of adding the duration denoted by _years_, _months_, _weeks_, and _days_ to _baseDate_ in the calendar system denoted by _calendar_, surpasses _isoDate2_ in the direction denoted by _sign_.
1068
+
If _weeks_ and _days_ are both zero, then _date1_ need not exist (for example, it could be February 30).
1069
+
</dd>
1070
+
</dl>
1071
+
<p>It performs the following steps when called:</p>
1072
+
<emu-alg>
1073
+
1. Let _yearMonth_ be RegulateNonISOYearMonth(_calendar_, _baseDate_, _years_).
1074
+
1. Let _endOfMonth_ be BalanceNonISODate(_calendar_, _yearMonth_.[[Year]], _yearMonth_.[[Month]] + _months_ + 1, 0).
1075
+
1. Let _baseDay_ be CalendarISOToDate(_calendar_, _baseDate_).[[Day]].
1076
+
1. If _weeks_ is not 0 or _days_ is not 0, then
1077
+
1. If _baseDay_ < _endOfMonth_.[[Day]], then
1078
+
1. Let _regulatedDay_ be _baseDay_.
1079
+
1. Else,
1080
+
1. Let _regulatedDay_ be _endOfMonth_.[[Day]].
1081
+
1. Let _balancedDate_ be BalanceNonISODate(_calendar_, _endOfMonth_.[[Year]], _endOfMonth_.[[Month]], _regulatedDay_ + 7 * _weeks_ + _days_).
1082
+
1. Let _y1_ be _balancedDate_.[[Year]].
1083
+
1. Let _m1_ be _balancedDate_.[[Month]].
1084
+
1. Let _d1_ be _balancedDate_.[[Day]].
1085
+
1. Else,
1086
+
1. Let _y1_ be _endOfMonth_.[[Year]].
1087
+
1. Let _m1_ be _endOfMonth_.[[Month]].
1088
+
1. Let _d1_ be _baseDay_.
1089
+
1. Let _calDate2_ be CalendarISOToDate(_calendar_, _isoDate2_).
@@ -853,19 +1113,35 @@ contributors: Google, Ecma International
853
1113
No fields larger than _largestUnit_ will be non-zero in the resulting Date Duration Record.
854
1114
</dd>
855
1115
</dl>
856
-
<p>The algorithm is implementation-defined, but all calendars follow the general steps given here, which is a generalization of the precise algorithm specified in CalendarDateUntil for *"iso8601"*.</p>
857
1116
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal-nonisodateuntil"></emu-xref>.</p>
858
1117
<p>It performs the following steps when called:</p>
859
1118
<emu-alg>
1119
+
1. Let _sign_ be -CompareISODate(_one_, _two_).
1120
+
1. If _sign_ = 0, return ZeroDateDuration().
1121
+
1. Let _years_ be 0.
860
1122
1. If _largestUnit_ is ~year~, then
861
-
1. Add (without constraining) as many years as possible to _one_, in the direction from _one_ to _two_, without surpassing _two_. "Surpassing" here (and in all steps below) means to compare years numerically, then month codes lexicographically, then days numerically; if any of them exceed _two_ in the direction from _one_ to _two_, then _two_ is surpassed.
862
-
1. Constrain _one_ to a real year and month, not taking day into account. This step only matters for lunisolar calendars.
863
-
1. If _largestUnit_ is ~year~ or ~month~, then
864
-
1. Add (without constraining) as many months as possible to _one_ without surpassing _two_.
865
-
1. Constrain _one_ to a real year, month, and day.
866
-
1. If _largestUnit_ is ~week~, add as many weeks as possible to _one_ without surpassing _two_.
867
-
1. Add as many days as possible to _one_ until it is equal to _two_.
868
-
1. Return a Date Duration Record of the number of years, months, weeks, and days added.
1123
+
1. Let _candidateYears_ be _sign_.
1124
+
1. Repeat, while NonISODateSurpasses(_calendar_, _sign_, _one_, _two_, _candidateYears_, 0, 0, 0) is *false*,
1125
+
1. Set _years_ to _candidateYears_.
1126
+
1. Set _candidateYears_ to _candidateYears_ + _sign_.
1127
+
1. Let _months_ be 0.
1128
+
1. If _largestUnit_ is ~year~ or _largestUnit_ is ~month~, then
1129
+
1. Let _candidateMonths_ be _sign_.
1130
+
1. Repeat, while NonISODateSurpasses(_calendar_, _sign_, _one_, _two_, _years_, _candidateMonths_, 0, 0) is *false*,
1131
+
1. Set _months_ to _candidateMonths_.
1132
+
1. Set _candidateMonths_ to _candidateMonths_ + _sign_.
1133
+
1. Let _weeks_ be 0.
1134
+
1. If _largestUnit_ is ~week~, then
1135
+
1. Let _candidateWeeks_ be _sign_.
1136
+
1. Repeat, while NonISODateSurpasses(_calendar_, _sign_, _one_, _two_, _years_, _months_, _candidateWeeks_, 0) is *false*,
1137
+
1. Set _weeks_ to _candidateWeeks_.
1138
+
1. Set _candidateWeeks_ to _candidateWeeks_ + sign.
1139
+
1. Let _days_ be 0.
1140
+
1. Let _candidateDays_ be _sign_.
1141
+
1. Repeat, while NonISODateSurpasses(_calendar_, _sign_, _one_, _two_, _years_, _months_, _weeks_, _candidateDays_) is *false*,
1142
+
1. Set _days_ to _candidateDays_.
1143
+
1. Set _candidateDays_ to _candidateDays_ + _sign_.
0 commit comments