mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:17:36 +00:00
LibJS: Disallow one day long time zone offsets
This is a normative change in the Temporal spec.
See: 9cc8b29b
This commit is contained in:
parent
1167fdb17a
commit
1b0ca52c54
7 changed files with 83 additions and 10 deletions
|
@ -33,7 +33,7 @@ describe("correct behavior", () => {
|
|||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor() {
|
||||
return 86400000000000;
|
||||
return 86399999999999;
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,7 @@ describe("correct behavior", () => {
|
|||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor() {
|
||||
return -86400000000000;
|
||||
return -86399999999999;
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -72,6 +72,21 @@ describe("correct behavior", () => {
|
|||
});
|
||||
|
||||
expect(timeZoneTested).toBeTrue();
|
||||
|
||||
test("cannot have a time zone with more than a day", () => {
|
||||
[86400000000000, -86400000000000, 86400000000001, 86400000000002].forEach(offset => {
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor() {
|
||||
return offset;
|
||||
},
|
||||
};
|
||||
expect(() => Temporal.Now.plainDateTime(calendar, timeZone)).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid offset nanoseconds value, must be in range -86400 * 10^9 + 1 to 86400 * 10^9 - 1"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue