Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normative: Handle days overflow in BalancePossiblyInfiniteTimeDuratio…
…nRelative Return an overflow marker when `𝔽(days)` is infinite. Strictly speaking a normative change, but can only happen when there are over 1e292 iterations in NanosecondsToDays. When passing a finite `𝔽(days)` to CreateTimeDurationRecord, CreateTimeDurationRecord can't fail anymore, so it's now marked as infallible. Example how to trigger infinite days in theory: ```js let cal = new class extends Temporal.Calendar { #dateUntil = 0; dateUntil(one, two, options) { if (this.#dateUntil++ === 0) { return Temporal.Duration.from({days: Number.MAX_VALUE}) } return super.dateUntil(one, two, options); } #dateAdd = 0; dateAdd(date, duration, options) { if (this.#dateAdd++ === 0) { return date; } if (duration.days > 1) { return date; } return super.dateAdd(date, duration, options) } }("iso8601"); let tz = new class extends Temporal.TimeZone { #getPossibleInstantsFor = 0n; getPossibleInstantsFor(dateTime) { if (this.#getPossibleInstantsFor++ < 10n**292n) { return [new Temporal.Instant(0n)]; } return super.getPossibleInstantsFor(dateTime); } }("UTC"); let zdt = new Temporal.ZonedDateTime(0n, tz, cal); let d = Temporal.Duration.from({nanoseconds: 1}); let r = d.total({unit: "days", relativeTo: zdt}) ```
- Loading branch information