Skip to content

Commit 1a837de

Browse files
committed
Editorial: Replace BalanceISODate with AddDaysToISODate
1 parent aff933a commit 1a837de

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

spec/calendar.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ <h1>
495495
1. If _calendar_ is *"iso8601"*, then
496496
1. Let _intermediate_ be BalanceISOYearMonth(_isoDate_.[[Year]] + _duration_.[[Years]], _isoDate_.[[Month]] + _duration_.[[Months]]).
497497
1. Set _intermediate_ to ? RegulateISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _isoDate_.[[Day]], _overflow_).
498-
1. Let _d_ be _intermediate_.[[Day]] + _duration_.[[Days]] + 7 × _duration_.[[Weeks]].
499-
1. Let _result_ be BalanceISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _d_).
498+
1. Let _days_ be _duration_.[[Days]] + 7 × _duration_.[[Weeks]].
499+
1. Let _result_ be AddDaysToISODate(_intermediate_, _days_).
500500
1. Else,
501501
1. Let _result_ be an implementation-defined ISO Date Record, or throw a *RangeError* exception, as described below.
502502
1. If ISODateWithinLimits(_result_) is *false*, throw a *RangeError* exception.
@@ -547,18 +547,18 @@ <h1>
547547
1. Let _weeks_ be 0.
548548
1. If _largestUnit_ is ~week~, then
549549
1. Let _candidateWeeks_ be _sign_.
550-
1. Set _intermediate_ to BalanceISODate(_constrained_.[[Year]], _constrained_.[[Month]], _constrained_.[[Day]] + 7 × _candidateWeeks_).
550+
1. Set _intermediate_ to AddDaysToISODate(_constrained_, 7 × _candidateWeeks_).
551551
1. Repeat, while ISODateSurpasses(_sign_, _intermediate_.[[Year]], _intermediate_.[[Month]], _intermediate_.[[Day]], _two_) is *false*,
552552
1. Set _weeks_ to _candidateWeeks_.
553553
1. Set _candidateWeeks_ to _candidateWeeks_ + sign.
554-
1. Set _intermediate_ to BalanceISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _intermediate_.[[Day]] + 7 × _sign_).
554+
1. Set _intermediate_ to AddDaysToISODate(_intermediate_, 7 × _sign_).
555555
1. Let _days_ be 0.
556556
1. Let _candidateDays_ be _sign_.
557-
1. Set _intermediate_ to BalanceISODate(_constrained_.[[Year]], _constrained_.[[Month]], _constrained_.[[Day]] + 7 × _weeks_ + _candidateDays_).
557+
1. Set _intermediate_ to AddDaysToISODate(_constrained_, 7 × _weeks_ + _candidateDays_).
558558
1. Repeat, while ISODateSurpasses(_sign_, _intermediate_.[[Year]], _intermediate_.[[Month]], _intermediate_.[[Day]], _two_) is *false*,
559559
1. Set _days_ to _candidateDays_.
560560
1. Set _candidateDays_ to _candidateDays_ + _sign_.
561-
1. Set _intermediate_ to BalanceISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _intermediate_.[[Day]] + _sign_).
561+
1. Set _intermediate_ to AddDaysToISODate(_intermediate_, _sign_).
562562
1. Return ! CreateDateDurationRecord(_years_, _months_, _weeks_, _days_).
563563
1. Return an implementation-defined Date Duration Record as described above.
564564
</emu-alg>

spec/duration.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ <h1>
16141614
1. Else if _unit_ is ~week~, then
16151615
1. Let _yearsMonths_ be ! AdjustDateDurationRecord(_duration_.[[Date]], 0, 0).
16161616
1. Let _weeksStart_ be ? CalendarDateAdd(_calendar_, _isoDateTime_.[[ISODate]], _yearsMonths_, ~constrain~).
1617-
1. Let _weeksEnd_ be BalanceISODate(_weeksStart_.[[Year]], _weeksStart_.[[Month]], _weeksStart_.[[Day]] + _duration_.[[Date]].[[Days]]).
1617+
1. Let _weeksEnd_ be AddDaysToISODate(_weeksStart_, _duration_.[[Date]].[[Days]]).
16181618
1. Let _untilResult_ be CalendarDateUntil(_calendar_, _weeksStart_, _weeksEnd_, ~week~).
16191619
1. Let _weeks_ be RoundNumberToIncrement(_duration_.[[Date]].[[Weeks]] + _untilResult_.[[Weeks]], _increment_, ~trunc~).
16201620
1. Let _r1_ be _weeks_.
@@ -1692,7 +1692,7 @@ <h1>
16921692
<emu-alg>
16931693
1. Let _start_ be ? CalendarDateAdd(_calendar_, _isoDateTime_.[[ISODate]], _duration_.[[Date]], ~constrain~).
16941694
1. Let _startDateTime_ be CombineISODateAndTimeRecord(_start_, _isoDateTime_.[[Time]]).
1695-
1. Let _endDate_ be BalanceISODate(_start_.[[Year]], _start_.[[Month]], _start_.[[Day]] + _sign_).
1695+
1. Let _endDate_ be AddDaysToISODate(_start_, _sign_).
16961696
1. Let _endDateTime_ be CombineISODateAndTimeRecord(_endDate_, _isoDateTime_.[[Time]]).
16971697
1. Let _startEpochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _startDateTime_, ~compatible~).
16981698
1. Let _endEpochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _endDateTime_, ~compatible~).

spec/plaindate.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -773,23 +773,22 @@ <h1>
773773
</emu-alg>
774774
</emu-clause>
775775

776-
<emu-clause id="sec-temporal-balanceisodate" type="abstract operation">
776+
<emu-clause id="sec-temporal-adddaystoisodate" type="abstract operation">
777777
<h1>
778-
BalanceISODate (
779-
_year_: an integer,
780-
_month_: an integer,
781-
_day_: an integer,
778+
AddDaysToISODate (
779+
_isoDate_: an ISO Date Record,
780+
_days_: an integer,
782781
): an ISO Date Record
783782
</h1>
784783
<dl class="header">
785784
<dt>description</dt>
786785
<dd>
787-
It converts the given _year_, _month_, and _day_ into a valid calendar date in the ISO 8601 calendar as given by IsValidISODate, by overflowing out-of-range _month_ or _day_ values into the next-highest unit.
786+
It adds _days_ to _isoDate_ into a valid calendar date in the ISO 8601 calendar as given by IsValidISODate, by overflowing out-of-range month or day values into the next-highest unit.
788787
This date may be outside the range given by ISODateTimeWithinLimits.
789788
</dd>
790789
</dl>
791790
<emu-alg>
792-
1. Let _epochDays_ be ISODateToEpochDays(_year_, _month_ - 1, _day_).
791+
1. Let _epochDays_ be ISODateToEpochDays(_isoDate_.[[Year]], _isoDate_.[[Month]] - 1, _isoDate_.[[Day]]) + _days_.
793792
1. Let _ms_ be EpochDaysToEpochMs(_epochDays_, 0).
794793
1. Return CreateISODateRecord(EpochTimeToEpochYear(_ms_), EpochTimeToMonthInYear(_ms_) + 1, EpochTimeToDate(_ms_)).
795794
</emu-alg>

spec/plaindatetime.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ <h1>
849849
</dl>
850850
<emu-alg>
851851
1. Let _balancedTime_ be BalanceTime(_isoDateTime_.[[Time]].[[Hour]], _isoDateTime_.[[Time]].[[Minute]], _isoDateTime_.[[Time]].[[Second]], _isoDateTime_.[[Time]].[[Millisecond]], _isoDateTime_.[[Time]].[[Microsecond]], _isoDateTime_.[[Time]].[[Nanosecond]] + _nanoseconds_).
852-
1. Let _balancedDate_ be BalanceISODate(_isoDateTime_.[[ISODate]].[[Year]], _isoDateTime_.[[ISODate]].[[Month]], _isoDateTime_.[[ISODate]].[[Day]] + _balancedTime_.[[Days]]).
852+
1. Let _balancedDate_ be AddDaysToISODate(_isoDateTime_.[[ISODate]], _balancedTime_.[[Days]]).
853853
1. Return CombineISODateAndTimeRecord(_balancedDate_, _balancedTime_).
854854
</emu-alg>
855855
</emu-clause>
@@ -935,7 +935,7 @@ <h1>
935935
<emu-alg>
936936
1. Assert: ISODateTimeWithinLimits(_isoDateTime_) is *true*.
937937
1. Let _roundedTime_ be RoundTime(_isoDateTime_.[[Time]], _increment_, _unit_, _roundingMode_).
938-
1. Let _balanceResult_ be BalanceISODate(_isoDateTime_.[[ISODate]].[[Year]], _isoDateTime_.[[ISODate]].[[Month]], _isoDateTime_.[[ISODate]].[[Day]] + _roundedTime_.[[Days]]).
938+
1. Let _balanceResult_ be AddDaysToISODate(_isoDateTime_.[[ISODate]], _roundedTime_.[[Days]]).
939939
1. Return CombineISODateAndTimeRecord(_balanceResult_, _roundedTime_).
940940
</emu-alg>
941941
</emu-clause>
@@ -964,7 +964,7 @@ <h1>
964964
1. Let _dateSign_ be CompareISODate(_isoDateTime2_.[[ISODate]], _isoDateTime1_.[[ISODate]]).
965965
1. Let _adjustedDate_ be _isoDateTime2_.[[ISODate]].
966966
1. If _timeSign_ = -_dateSign_, then
967-
1. Set _adjustedDate_ to BalanceISODate(_adjustedDate_.[[Year]], _adjustedDate_.[[Month]], _adjustedDate_.[[Day]] + _timeSign_).
967+
1. Set _adjustedDate_ to AddDaysToISODate(_adjustedDate_, _timeSign_).
968968
1. Set _timeDuration_ to ? Add24HourDaysToTimeDuration(_timeDuration_, -_timeSign_).
969969
1. Let _dateLargestUnit_ be LargerOfTwoTemporalUnits(~day~, _largestUnit_).
970970
1. Let _dateDifference_ be CalendarDateUntil(_calendar_, _isoDateTime1_.[[ISODate]], _adjustedDate_, _dateLargestUnit_).

spec/plainyearmonth.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ <h1>
648648
1. If _sign_ &lt; 0, then
649649
1. Let _oneMonthDuration_ be ! CreateDateDurationRecord(0, 1, 0, 0).
650650
1. Let _nextMonth_ be ? CalendarDateAdd(_calendar_, _intermediateDate_, _oneMonthDuration_, ~constrain~).
651-
1. Let _date_ be BalanceISODate(_nextMonth_.[[Year]], _nextMonth_.[[Month]], _nextMonth_.[[Day]] - 1).
651+
1. Let _date_ be AddDaysToISODate(_nextMonth_, -1).
652652
1. Assert: ISODateWithinLimits(_date_) is *true*.
653653
1. Else,
654654
1. Let _date_ be _intermediateDate_.

spec/timezone.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@ <h1>
316316
1. If _disambiguation_ is ~earlier~, then
317317
1. Let _timeDuration_ be TimeDurationFromComponents(0, 0, 0, 0, 0, -_nanoseconds_).
318318
1. Let _earlierTime_ be AddTime(_isoDateTime_.[[Time]], _timeDuration_).
319-
1. Let _earlierDate_ be BalanceISODate(_isoDateTime_.[[ISODate]].[[Year]], _isoDateTime_.[[ISODate]].[[Month]], _isoDateTime_.[[ISODate]].[[Day]] + _earlierTime_.[[Days]]).
319+
1. Let _earlierDate_ be AddDaysToISODate(_isoDateTime_.[[ISODate]], _earlierTime_.[[Days]]).
320320
1. Let _earlierDateTime_ be CombineISODateAndTimeRecord(_earlierDate_, _earlierTime_).
321321
1. Set _possibleEpochNs_ to ? GetPossibleEpochNanoseconds(_timeZone_, _earlierDateTime_).
322322
1. Assert: _possibleEpochNs_ is not empty.
323323
1. Return _possibleEpochNs_[0].
324324
1. Assert: _disambiguation_ is ~compatible~ or ~later~.
325325
1. Let _timeDuration_ be TimeDurationFromComponents(0, 0, 0, 0, 0, _nanoseconds_).
326326
1. Let _laterTime_ be AddTime(_isoDateTime_.[[Time]], _timeDuration_).
327-
1. Let _laterDate_ be BalanceISODate(_isoDateTime_.[[ISODate]].[[Year]], _isoDateTime_.[[ISODate]].[[Month]], _isoDateTime_.[[ISODate]].[[Day]] + _laterTime_.[[Days]]).
327+
1. Let _laterDate_ be AddDaysToISODate(_isoDateTime_.[[ISODate]], _laterTime_.[[Days]]).
328328
1. Let _laterDateTime_ be CombineISODateAndTimeRecord(_laterDate_, _laterTime_).
329329
1. Set _possibleEpochNs_ to ? GetPossibleEpochNanoseconds(_timeZone_, _laterDateTime_).
330330
1. Set _n_ to _possibleEpochNs_'s length.

spec/zoneddatetime.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ <h1>get Temporal.ZonedDateTime.prototype.hoursInDay</h1>
398398
1. Let _timeZone_ be _zonedDateTime_.[[TimeZone]].
399399
1. Let _isoDateTime_ be GetISODateTimeFor(_timeZone_, _zonedDateTime_.[[EpochNanoseconds]]).
400400
1. Let _today_ be _isoDateTime_.[[ISODate]].
401-
1. Let _tomorrow_ be BalanceISODate(_today_.[[Year]], _today_.[[Month]], _today_.[[Day]] + 1).
401+
1. Let _tomorrow_ be AddDaysToISODate(_today_, 1).
402402
1. Let _todayNs_ be ? GetStartOfDay(_timeZone_, _today_).
403403
1. Let _tomorrowNs_ be ? GetStartOfDay(_timeZone_, _tomorrow_).
404404
1. Let _diff_ be TimeDurationFromEpochNanosecondsDifference(_tomorrowNs_, _todayNs_).
@@ -651,7 +651,7 @@ <h1>Temporal.ZonedDateTime.prototype.round ( _roundTo_ )</h1>
651651
1. Let _isoDateTime_ be GetISODateTimeFor(_timeZone_, _thisNs_).
652652
1. If _smallestUnit_ is ~day~, then
653653
1. Let _dateStart_ be _isoDateTime_.[[ISODate]].
654-
1. Let _dateEnd_ be BalanceISODate(_dateStart_.[[Year]], _dateStart_.[[Month]], _dateStart_.[[Day]] + 1).
654+
1. Let _dateEnd_ be AddDaysToISODate(_dateStart_, 1).
655655
1. Let _startNs_ be ? GetStartOfDay(_timeZone_, _dateStart_).
656656
1. Assert: _thisNs__startNs_.
657657
1. Let _endNs_ be ? GetStartOfDay(_timeZone_, _dateEnd_).
@@ -1127,7 +1127,7 @@ <h1>
11271127
1. If TimeDurationSign(_timeDuration_) = -_sign_, set _dayCorrection_ to _dayCorrection_ + 1.
11281128
1. Let _success_ be *false*.
11291129
1. Repeat, while _dayCorrection__maxDayCorrection_ and _success_ is *false*,
1130-
1. Let _intermediateDate_ be BalanceISODate(_endDateTime_.[[ISODate]].[[Year]], _endDateTime_.[[ISODate]].[[Month]], _endDateTime_.[[ISODate]].[[Day]] - _dayCorrection_ × _sign_).
1130+
1. Let _intermediateDate_ be AddDaysToISODate(_endDateTime_.[[ISODate]], _dayCorrection_ × -_sign_).
11311131
1. Let _intermediateDateTime_ be CombineISODateAndTimeRecord(_intermediateDate_, _startDateTime_.[[Time]]).
11321132
1. Let _intermediateNs_ be ? GetEpochNanosecondsFor(_timeZone_, _intermediateDateTime_, ~compatible~).
11331133
1. Set _timeDuration_ to TimeDurationFromEpochNanosecondsDifference(_ns2_, _intermediateNs_).

0 commit comments

Comments
 (0)