mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 18:00:16 +00:00
LibJS: Begin implementing the relativeTo option of Duration.compare
This commit is contained in:
parent
06593b1894
commit
0befd52725
Notes:
github-actions[bot]
2024-11-23 13:47:08 +00:00
Author: https://github.com/trflynn89
Commit: 0befd52725
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2513
Reviewed-by: https://github.com/shannonbooth ✅
4 changed files with 55 additions and 3 deletions
|
@ -27,6 +27,26 @@ describe("correct behavior", () => {
|
|||
const duration2 = "P2D";
|
||||
checkCommonResults(duration1, duration2);
|
||||
});
|
||||
|
||||
test("relative to plain date", () => {
|
||||
const oneMonth = new Temporal.Duration(0, 1);
|
||||
const thirtyDays = new Temporal.Duration(0, 0, 0, 30);
|
||||
|
||||
let result = Temporal.Duration.compare(oneMonth, thirtyDays, {
|
||||
relativeTo: Temporal.PlainDate.from("2018-04-01"),
|
||||
});
|
||||
expect(result).toBe(0);
|
||||
|
||||
result = Temporal.Duration.compare(oneMonth, thirtyDays, {
|
||||
relativeTo: Temporal.PlainDate.from("2018-03-01"),
|
||||
});
|
||||
expect(result).toBe(1);
|
||||
|
||||
result = Temporal.Duration.compare(oneMonth, thirtyDays, {
|
||||
relativeTo: Temporal.PlainDate.from("2018-02-01"),
|
||||
});
|
||||
expect(result).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue