Skip to content

Commit

Permalink
Editorial: Don't use 'is' for numeric equality
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato authored and Ms2ger committed May 15, 2024
1 parent efed342 commit f1b611f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
48 changes: 24 additions & 24 deletions spec/abstractops.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1>
<emu-alg>
1. Let _resolvedYear_ be _year_ + floor(_month_ / 12).
1. Let _resolvedMonth_ be _month_ modulo 12.
1. Find a time _t_ such that EpochTimeToEpochYear(_t_) is _resolvedYear_, EpochTimeToMonthInYear(_t_) is _resolvedMonth_, and EpochTimeToDate(_t_) is 1.
1. Find a time _t_ such that EpochTimeToEpochYear(_t_) = _resolvedYear_, EpochTimeToMonthInYear(_t_) = _resolvedMonth_, and EpochTimeToDate(_t_) = 1.
1. Return EpochTimeToDayNumber(_t_) + _date_ - 1.
</emu-alg>
<emu-note type="editor"> This operation corresponds to ECMA-262 operation MakeDay(_year_, _month_, _date_). It calculates the result in mathematical values instead of Number values. These two operations would be unified when https://github.com/tc39/ecma262/issues/1087 is fixed.</emu-note>
Expand Down Expand Up @@ -88,8 +88,8 @@ <h1>Date Equations</h1>
<p>The following function returns 1 for a time within leap year otherwise it returns 0:</p>
<emu-eqn id="eqn-mathematicalinleapyear" aoid="MathematicalInLeapYear">
MathematicalInLeapYear(_t_)
= 0 if MathematicalDaysInYear(EpochTimeToEpochYear(_t_)) is 365
= 1 if MathematicalDaysInYear(EpochTimeToEpochYear(_t_)) is 366
= 0 if MathematicalDaysInYear(EpochTimeToEpochYear(_t_)) = 365
= 1 if MathematicalDaysInYear(EpochTimeToEpochYear(_t_)) = 366
</emu-eqn>
<p>The month number for a time _t_ is given by:</p>
<emu-eqn id="eqn-epochtimetomonthinyear" aoid="EpochTimeToMonthInYear">
Expand All @@ -113,18 +113,18 @@ <h1>Date Equations</h1>
<p>The date number for a time _t_ is given by:</p>
<emu-eqn id="eqn-epochtimetodate" aoid="EpochTimeToDate">
EpochTimeToDate(_t_)
= EpochTimeToDayInYear(_t_) + 1 if EpochTimeToMonthInYear(_t_) is 0
= EpochTimeToDayInYear(_t_) - 30 if EpochTimeToMonthInYear(_t_) is 1
= EpochTimeToDayInYear(_t_) - 58 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 2
= EpochTimeToDayInYear(_t_) - 89 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 3
= EpochTimeToDayInYear(_t_) - 119 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 4
= EpochTimeToDayInYear(_t_) - 150 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 5
= EpochTimeToDayInYear(_t_) - 180 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 6
= EpochTimeToDayInYear(_t_) - 211 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 7
= EpochTimeToDayInYear(_t_) - 242 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 8
= EpochTimeToDayInYear(_t_) - 272 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 9
= EpochTimeToDayInYear(_t_) - 303 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 10
= EpochTimeToDayInYear(_t_) - 333 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) is 11
= EpochTimeToDayInYear(_t_) + 1 if EpochTimeToMonthInYear(_t_) = 0
= EpochTimeToDayInYear(_t_) - 30 if EpochTimeToMonthInYear(_t_) = 1
= EpochTimeToDayInYear(_t_) - 58 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 2
= EpochTimeToDayInYear(_t_) - 89 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 3
= EpochTimeToDayInYear(_t_) - 119 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 4
= EpochTimeToDayInYear(_t_) - 150 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 5
= EpochTimeToDayInYear(_t_) - 180 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 6
= EpochTimeToDayInYear(_t_) - 211 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 7
= EpochTimeToDayInYear(_t_) - 242 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 8
= EpochTimeToDayInYear(_t_) - 272 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 9
= EpochTimeToDayInYear(_t_) - 303 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 10
= EpochTimeToDayInYear(_t_) - 333 - MathematicalInLeapYear(_t_) if EpochTimeToMonthInYear(_t_) = 11
</emu-eqn>
<p>The weekday for a particular time _t_ is defined as:</p>
<emu-eqn id="eqn-epochtimetoweekday" aoid="EpochTimeToWeekDay">EpochTimeToWeekDay(_t_) =(EpochTimeToDayNumber(_t_) + 4) modulo 7</emu-eqn>
Expand Down Expand Up @@ -654,25 +654,25 @@ <h1>
[[Unit]]: *"nanosecond"*,
[[Increment]]: 1
}.
1. If _fractionalDigitCount_ is 0, then
1. If _fractionalDigitCount_ = 0, then
1. Return the Record {
[[Precision]]: 0,
[[Unit]]: *"second"*,
[[Increment]]: 1
}.
1. If _fractionalDigitCount_ is 1, 2, or 3, then
1. If _fractionalDigitCount_ is in the inclusive interval from 1 to 3, then
1. Return the Record {
[[Precision]]: _fractionalDigitCount_,
[[Unit]]: *"millisecond"*,
[[Increment]]: 10<sup>3 - _fractionalDigitCount_</sup>
}.
1. If _fractionalDigitCount_ is 4, 5, or 6, then
1. If _fractionalDigitCount_ is in the inclusive interval from 4 to 6, then
1. Return the Record {
[[Precision]]: _fractionalDigitCount_,
[[Unit]]: *"microsecond"*,
[[Increment]]: 10<sup>6 - _fractionalDigitCount_</sup>
}.
1. Assert: _fractionalDigitCount_ is 7, 8, or 9.
1. Assert: _fractionalDigitCount_ is in the inclusive interval from 7 to 9.
1. Return the Record {
[[Precision]]: _fractionalDigitCount_,
[[Unit]]: *"nanosecond"*,
Expand Down Expand Up @@ -899,11 +899,11 @@ <h1>
</dl>
<emu-alg>
1. If _precision_ is *"auto"*, then
1. If _subSecondNanoseconds_ is 0, return the empty String.
1. If _subSecondNanoseconds_ = 0, return the empty String.
1. Let _fractionString_ be ToZeroPaddedDecimalString(_subSecondNanoseconds_, 9).
1. Set _fractionString_ to the longest prefix of _fractionString_ ending with a code unit other than 0x0030 (DIGIT ZERO).
1. Else,
1. If _precision_ is 0, return the empty String.
1. If _precision_ = 0, return the empty String.
1. Let _fractionString_ be ToZeroPaddedDecimalString(_subSecondNanoseconds_, 9).
1. Set _fractionString_ to the substring of _fractionString_ from 0 to _precision_.
1. Return the string-concatenation of the code unit 0x002E (FULL STOP) and _fractionString_.
Expand Down Expand Up @@ -1066,7 +1066,7 @@ <h1>
<dd>It considers _x_, bracketed below by _r1_ and above by _r2_, and returns either _r1_ or _r2_ according to _unsignedRoundingMode_.</dd>
</dl>
<emu-alg>
1. If _x_ is equal to _r1_, return _r1_.
1. If _x_ = _r1_, return _r1_.
1. Assert: _r1_ &lt; _x_ &lt; _r2_.
1. Assert: _unsignedRoundingMode_ is not *undefined*.
1. If _unsignedRoundingMode_ is ~zero~, return _r1_.
Expand All @@ -1080,7 +1080,7 @@ <h1>
1. If _unsignedRoundingMode_ is ~half-infinity~, return _r2_.
1. Assert: _unsignedRoundingMode_ is ~half-even~.
1. Let _cardinality_ be <emu-eqn>(_r1_ / (_r2__r1_)) modulo 2</emu-eqn>.
1. If _cardinality_ is 0, return _r1_.
1. If _cardinality_ = 0, return _r1_.
1. Return _r2_.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -1550,7 +1550,7 @@ <h1>
1. Let _secondMV_ be 0.
1. Else,
1. Let _secondMV_ be ℝ(StringToNumber(CodePointsToString(_second_))).
1. If _secondMV_ is 60, then
1. If _secondMV_ = 60, then
1. Set _secondMV_ to 59.
1. If _fSeconds_ is not empty, then
1. Let _fSecondsDigits_ be the substring of CodePointsToString(_fSeconds_) from 1.
Expand Down
10 changes: 5 additions & 5 deletions spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ <h1>
<emu-alg>
1. If _month_ is 1, 3, 5, 7, 8, 10, or 12, return 31.
1. If _month_ is 4, 6, 9, or 11, return 30.
1. Assert: _month_ is 2.
1. Assert: _month_ = 2.
1. Return 28 + MathematicalInLeapYear(EpochTimeForYear(_year_)).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -1090,12 +1090,12 @@ <h1>
1. If _week_ &lt; 1, then
1. NOTE: This is the last week of the previous year.
1. Let _dayOfJan1st_ be ToISODayOfWeek(_year_, 1, 1).
1. If _dayOfJan1st_ is _friday_, then
1. If _dayOfJan1st_ = _friday_, then
1. Return Year-Week Record { [[Week]]: _maxWeekNumber_, [[Year]]: _year_ - 1 }.
1. If _dayOfJan1st_ is _saturday_, and MathematicalInLeapYear(EpochTimeForYear(_year_ - 1)) is 1, then
1. If _dayOfJan1st_ = _saturday_, and MathematicalInLeapYear(EpochTimeForYear(_year_ - 1)) = 1, then
1. Return Year-Week Record { [[Week]]: _maxWeekNumber_. [[Year]]: _year_ - 1 }.
1. Return Year-Week Record { [[Week]]: _maxWeekNumber_ - 1, [[Year]]: _year_ - 1 }.
1. If _week_ is _maxWeekNumber_, then
1. If _week_ = _maxWeekNumber_, then
1. Let _daysInYear_ be MathematicalDaysInYear(_year_).
1. Let _daysLaterInYear_ be _daysInYear_ - _dayOfYear_.
1. Let _daysAfterThursday_ be _thursday_ - _dayOfWeek_.
Expand Down Expand Up @@ -2215,7 +2215,7 @@ <h1>Temporal.Calendar.prototype.inLeapYear ( _temporalDateLike_ )</h1>
1. If _temporalDateLike_ is not an Object or _temporalDateLike_ does not have an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], or [[InitializedTemporalYearMonth]] internal slot, then
1. Set _temporalDateLike_ to ? ToTemporalDate(_temporalDateLike_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. If MathematicalInLeapYear(EpochTimeForYear(_temporalDateLike_.[[ISOYear]])) is 1, then
1. If MathematicalInLeapYear(EpochTimeForYear(_temporalDateLike_.[[ISOYear]])) = 1, then
1. Let _inLeapYear_ be *true*.
1. Else,
1. Let _inLeapYear_ be *false*.
Expand Down
2 changes: 1 addition & 1 deletion spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ <h1>
<emu-alg>
1. Assert: IsValidISODate(_y2_, _m2_, _d2_).
1. Let _comparison_ be CompareISODate(_y1_, _m1_, _d1_, _y2_, _m2_, _d2_).
1. If _sign_ &times; _comparison_ is 1, return *true*.
1. If _sign_ &times; _comparison_ = 1, return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>
Expand Down
4 changes: 2 additions & 2 deletions spec/plaindatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ <h1>Temporal.PlainDateTime.prototype.round ( _roundTo_ )</h1>
1. Assert: _maximum_ is not *undefined*.
1. Let _inclusive_ be *false*.
1. Perform ? ValidateTemporalRoundingIncrement(_roundingIncrement_, _maximum_, _inclusive_).
1. If _smallestUnit_ is *"nanosecond"* and _roundingIncrement_ is 1, then
1. If _smallestUnit_ is *"nanosecond"* and _roundingIncrement_ = 1, then
1. Return ! CreateTemporalDateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _dateTime_.[[Calendar]]).
1. Let _result_ be RoundISODateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _roundingIncrement_, _smallestUnit_, _roundingMode_).
1. Return ? CreateTemporalDateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]], _dateTime_.[[Calendar]]).
Expand Down Expand Up @@ -1339,7 +1339,7 @@ <h1>
1. Let _timeSign_ be NormalizedTimeDurationSign(_timeDuration_).
1. Let _dateSign_ be CompareISODate(_y2_, _mon2_, _d2_, _y1_, _mon1_, _d1_).
1. Let _adjustedDate_ be CreateISODateRecord(_y1_, _mon1_, _d1_).
1. If _timeSign_ is -_dateSign_, then
1. If _timeSign_ = -_dateSign_, then
1. Set _adjustedDate_ to BalanceISODate(_adjustedDate_.[[Year]], _adjustedDate_.[[Month]], _adjustedDate_.[[Day]] - _timeSign_).
1. Set _timeDuration_ to ? Add24HourDaysToNormalizedTimeDuration(_timeDuration_, -_timeSign_).
1. Let _date1_ be ! CreateTemporalDate(_adjustedDate_.[[Year]], _adjustedDate_.[[Month]], _adjustedDate_.[[Day]], _calendarRec_.[[Receiver]]).
Expand Down
4 changes: 2 additions & 2 deletions spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,9 @@ <h1>
<emu-alg>
1. If _year_ &lt; -271821 or _year_ &gt; 275760, then
1. Return *false*.
1. If _year_ is -271821 and _month_ &lt; 4, then
1. If _year_ = -271821 and _month_ &lt; 4, then
1. Return *false*.
1. If _year_ is 275760 and _month_ &gt; 9, then
1. If _year_ = 275760 and _month_ &gt; 9, then
1. Return *false*.
1. Return *true*.
</emu-alg>
Expand Down
6 changes: 3 additions & 3 deletions spec/zoneddatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ <h1>Temporal.ZonedDateTime.prototype.round ( _roundTo_ )</h1>
1. Assert: _maximum_ is not *undefined*.
1. Let _inclusive_ be *false*.
1. Perform ? ValidateTemporalRoundingIncrement(_roundingIncrement_, _maximum_, _inclusive_).
1. If _smallestUnit_ is *"nanosecond"* and _roundingIncrement_ is 1, then
1. If _smallestUnit_ is *"nanosecond"* and _roundingIncrement_ = 1, then
1. Return ! CreateTemporalZonedDateTime(_zonedDateTime_.[[Nanoseconds]], _zonedDateTime_.[[TimeZone]], _zonedDateTime_.[[Calendar]]).
1. Let _timeZoneRec_ be ? CreateTimeZoneMethodsRecord(_zonedDateTime_.[[TimeZone]], « ~get-offset-nanoseconds-for~, ~get-possible-instants-for~ »).
1. Let _instant_ be ! CreateTemporalInstant(_zonedDateTime_.[[Nanoseconds]]).
Expand Down Expand Up @@ -1433,7 +1433,7 @@ <h1>
</dl>
<p>Unless _ns1_ and _ns2_ are equal, _timeZoneRec_ must have looked up both `getOffsetNanosecondsFor` and `getPossibleInstantsFor`.</p>
<emu-alg>
1. If _ns1_ is _ns2_, then
1. If _ns1_ = _ns2_, then
1. Return ! CreateNormalizedDurationRecord(0, 0, 0, 0, ZeroTimeDuration()).
1. Let _endInstant_ be ! CreateTemporalInstant(_ns2_).
1. Let _endDateTime_ be ? GetPlainDateTimeFor(_timeZoneRec_, _endInstant_, _calendarRec_.[[Receiver]]).
Expand Down Expand Up @@ -1493,7 +1493,7 @@ <h1>
1. Let _durationRecord_ be CreateDurationRecord(0, 0, 0, 0, _result_.[[Hours]], _result_.[[Minutes]], _result_.[[Seconds]], _result_.[[Milliseconds]], _result_.[[Microseconds]], _result_.[[Nanoseconds]]).
1. Return the Record { [[DurationRecord]]: _durationRecord_, [[Total]]: _diffRecord_.[[Total]] }.
1. Let _difference_ be ? DifferenceZonedDateTime(_ns1_, _ns2_, _timeZoneRec_, _calendarRec_, _largestUnit_, _resolvedOptions_, _precalculatedPlainDateTime_).
1. If _smallestUnit_ is *"nanosecond"* and _roundingIncrement_ is 1, let _roundingGranularityIsNoop_ be *true*; else let _roundingGranularityIsNoop_ be *false*.
1. If _smallestUnit_ is *"nanosecond"* and _roundingIncrement_ = 1, let _roundingGranularityIsNoop_ be *true*; else let _roundingGranularityIsNoop_ be *false*.
1. If _roundingGranularityIsNoop_ is *true*, then
1. Let _timeResult_ be BalanceTimeDuration(_difference_.[[NormalizedTime]], *"hour"*).
1. Let _total_ be NormalizedTimeDurationSeconds(_difference_.[[NormalizedTime]]) × 10<sup>9</sup> + NormalizedTimeDurationSubseconds(_difference_.[[NormalizedTime]]).
Expand Down

0 comments on commit f1b611f

Please sign in to comment.