blob: dd912f46d458717468684a14445ad92be072f4a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.round
description: RangeError thrown if the calculated day length is zero
features: [Temporal]
---*/
class TimeZone extends Temporal.TimeZone {
#calls = 0;
getPossibleInstantsFor(dateTime) {
if (++this.#calls === 2) {
return super.getPossibleInstantsFor(dateTime.withCalendar("iso8601").subtract({ days: 1 }));
}
return super.getPossibleInstantsFor(dateTime);
}
}
const zdt = new Temporal.ZonedDateTime(0n, new TimeZone("UTC"));
assert.throws(RangeError, () => zdt.round({ smallestUnit: "day" }), `zero day-length with smallestUnit 'day'`);
reportCompare(0, 0);
|