Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fail on 31/12 #1677

Closed
guimard opened this issue Jan 1, 2025 · 2 comments
Closed

Test fail on 31/12 #1677

guimard opened this issue Jan 1, 2025 · 2 comments

Comments

@guimard
Copy link

guimard commented Jan 1, 2025

Describe the bug

The test fail on 31/12. Here is a simple patch:

--- a/test/datetime/relative.test.js
+++ b/test/datetime/relative.test.js
@@ -121,7 +121,9 @@
 test("DateTime#toRelativeCalendar picks the correct unit with no options", () => {
   const now = DateTime.now();
   const isLastDayOfMonth = now.endOf("month").day === now.day;
+  const isLastDayOfYear = now.endOf("year").day === now.day;
   expect(now.plus({ days: 1 }).toRelativeCalendar()).toBe(
+    isLastDayOfYear ? "next year" :
     isLastDayOfMonth ? "next month" : "tomorrow"
   );
 });

Reported by Debian: https://bugs.debian.org/109810

@vpzomtrrfrt
Copy link

the referenced debian bug predates the existence of luxon by over a decade

@diesieben07
Copy link
Collaborator

Thank you for the report. You are right, tests that depend on the current time of day are not great.

I don't agree with your patch though, the test should be split up into four tests, which test that this behavior works correctly on all combinations of "last day of the month: yes/no" and "last day of the year: yes/no".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants