Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw authored and ptomato committed Jun 13, 2024
1 parent a158741 commit f9e1475
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,25 @@ features: [Temporal]
"Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days"
);
}

// Test that 1-day backoff to maintain date/time sign compatibility backs-off from correct end
// while moving *forwards* in time and does not interfere with month boundaries
// https://github.com/tc39/proposal-temporal/issues/2820
{
TemporalHelpers.assertDuration(
new Temporal.PlainDateTime(2023, 2, 28, 3).since(new Temporal.PlainDateTime(2023, 4, 1, 2), { largestUnit: "years" }),
0, -1, 0, -3, -23, 0, 0, 0, 0, 0,
"Feb 28th (3am) to Apr 1st (2am) is -1 month, -3 days, and -23 hours"
);
}

// Test that 1-day backoff to maintain date/time sign compatibility backs-off from correct end
// while moving *backwards* in time and does not interfere with month boundaries
// https://github.com/tc39/proposal-temporal/issues/2820
{
TemporalHelpers.assertDuration(
new Temporal.PlainDateTime(2023, 3, 1, 2).since(new Temporal.PlainDateTime(2023, 1, 1, 3), { largestUnit: "years" }),
0, 1, 0, 30, 23, 0, 0, 0, 0, 0,
"Mar 1st (2am) to Jan 1st (3am) is 1 month, 30 days, and 23 hours"
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,25 @@ features: [Temporal]
"Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days"
);
}

// Test that 1-day backoff to maintain date/time sign compatibility backs-off from correct end
// while moving *backwards* in time and does not interfere with month boundaries
// https://github.com/tc39/proposal-temporal/issues/2820
{
TemporalHelpers.assertDuration(
new Temporal.PlainDateTime(2023, 2, 28, 3).until(new Temporal.PlainDateTime(2023, 4, 1, 2), { largestUnit: "years" }),
0, 1, 0, 3, 23, 0, 0, 0, 0, 0,
"Feb 28th (3am) to Apr 1st (2am) is 1 month, 3 days, and 23 hours"
);
}

// Test that 1-day backoff to maintain date/time sign compatibility backs-off from correct end
// while moving *forwards* in time and does not interfere with month boundaries
// https://github.com/tc39/proposal-temporal/issues/2820
{
TemporalHelpers.assertDuration(
new Temporal.PlainDateTime(2023, 3, 1, 2).until(new Temporal.PlainDateTime(2023, 1, 1, 3), { largestUnit: "years" }),
0, -1, 0, -30, -23, 0, 0, 0, 0, 0,
"Mar 1st (2am) to Jan 1st (3am) is -1 month, -30 days, and -23 hours"
);
}

0 comments on commit f9e1475

Please sign in to comment.