mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-28 12:18:56 +00:00
LibJS: Adjust ad-hoc clamping behavior in RegulateISODate
Instead of clamping to the limits allowed by ISOYearMonthWithinLimits, clamp to the limits allowed by the type we are converting to (i32). This allows some callers to then reject years outside that range.
This commit is contained in:
parent
d5b26183f3
commit
59162c8155
Notes:
github-actions[bot]
2025-01-17 09:09:06 +00:00
Author: https://github.com/trflynn89
Commit: 59162c8155
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3275
2 changed files with 13 additions and 6 deletions
|
@ -87,10 +87,15 @@ describe("errors", () => {
|
|||
});
|
||||
|
||||
test("relativeTo with invalid date", () => {
|
||||
const duration = new Temporal.Duration(0, 0, 0, 31);
|
||||
|
||||
expect(() => {
|
||||
const duration = new Temporal.Duration(0, 0, 0, 31);
|
||||
duration.total({ unit: "minute", relativeTo: "-271821-04-19" });
|
||||
}).toThrowWithMessage(RangeError, "Invalid ISO date time");
|
||||
|
||||
expect(() => {
|
||||
const duration = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
|
||||
const relativeTo = new Temporal.ZonedDateTime(864n * 10n ** 19n - 1n, "UTC");
|
||||
duration.total({ unit: "years", relativeTo: relativeTo });
|
||||
}).toThrowWithMessage(RangeError, "Invalid ISO date");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue