mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
LibJS: Require strict matching with a precise ZonedDateTime offset
This is a normative change in the Temporal proposal. See:
1117eaf
This commit is contained in:
parent
f091047159
commit
c8b4dc4847
Notes:
github-actions[bot]
2025-06-02 21:10:33 +00:00
Author: https://github.com/trflynn89
Commit: c8b4dc4847
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4966
3 changed files with 70 additions and 6 deletions
|
@ -67,6 +67,21 @@ describe("correct behavior", () => {
|
|||
});
|
||||
expect(result).toBe(-1);
|
||||
});
|
||||
|
||||
test("sub-minute time zone offset", () => {
|
||||
const duration1 = new Temporal.Duration(0, 0, 0, 31);
|
||||
const duration2 = new Temporal.Duration(0, 1);
|
||||
|
||||
let result = Temporal.Duration.compare(duration1, duration2, {
|
||||
relativeTo: "1970-01-01T00:00:00-00:45[Africa/Monrovia]",
|
||||
});
|
||||
expect(result).toBe(0);
|
||||
|
||||
result = Temporal.Duration.compare(duration1, duration2, {
|
||||
relativeTo: "1970-01-01T00:00:00-00:44:30[Africa/Monrovia]",
|
||||
});
|
||||
expect(result).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
|
@ -132,4 +147,27 @@ describe("errors", () => {
|
|||
"A starting point is required for comparing calendar units"
|
||||
);
|
||||
});
|
||||
|
||||
test("sub-minute time zone offset mismatch", () => {
|
||||
const duration1 = new Temporal.Duration(0, 0, 0, 31);
|
||||
const duration2 = new Temporal.Duration(0, 1);
|
||||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration1, duration2, {
|
||||
relativeTo: "1970-01-01T00:00:00-00:44:40[Africa/Monrovia]",
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid offset for the provided date and time in the current time zone"
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
Temporal.Duration.compare(duration1, duration2, {
|
||||
relativeTo: "1970-01-01T00:00:00-00:45:00[Africa/Monrovia]",
|
||||
});
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"Invalid offset for the provided date and time in the current time zone"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue