Skip to content

Commit 0d2d60e

Browse files
ptomato12wrigja
authored andcommitted
Implement check for negative day length in ZonedDateTime.round
This is the corresponding polyfill change to the spec change made in tc39/proposal-temporal#2261 UPSTREAM_COMMIT=a1314bd0a47ecf2f41b85d5888a233d15e8a62a8
1 parent 5f7b3fc commit 0d2d60e

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/zoneddatetime.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ export class ZonedDateTime implements Temporal.ZonedDateTime {
365365
const instantStart = ES.BuiltinTimeZoneGetInstantFor(timeZone, dtStart, 'compatible');
366366
const endNs = ES.AddZonedDateTime(instantStart, timeZone, calendar, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0);
367367
const dayLengthNs = JSBI.subtract(endNs, JSBI.BigInt(GetSlot(instantStart, EPOCHNANOSECONDS)));
368-
if (JSBI.equal(dayLengthNs, ZERO)) {
369-
throw new RangeError('cannot round a ZonedDateTime in a calendar with zero-length days');
368+
if (JSBI.lessThanOrEqual(dayLengthNs, ZERO)) {
369+
throw new RangeError('cannot round a ZonedDateTime in a calendar with zero or negative length days');
370370
}
371371
({ year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } = ES.RoundISODateTime(
372372
year,

test/expected-failures-todo-migrated-code.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,6 @@ built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfCeil.js
774774
built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfEven.js
775775
built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfFloor.js
776776
built-ins/Temporal/ZonedDateTime/prototype/round/roundingmode-halfTrunc.js
777-
built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-too-large.js
778-
built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-zero-or-negative.js
779777
built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-out-of-range.js
780778
built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-out-of-range.js
781779
built-ins/Temporal/ZonedDateTime/prototype/since/argument-calendar-fields-undefined.js

0 commit comments

Comments
 (0)