We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug DateTime.set({ weekday: X }) sometimes returns a date in the past, and sometimes in the future. To Reproduce
luxon.DateTime.fromISO('2023-10-01T20:24:00Z').set({ weekday: 3 }).toISO() >'2023-09-27T16:24:00.000-04:00' luxon.DateTime.fromISO('2023-10-02T20:24:00Z').set({ weekday: 3 }).toISO() >'2023-10-04T16:24:00.000-04:00'
Actual vs Expected behavior All values return a future date
Additional context I think in moment.js, setting a weekday will always return a future date
The text was updated successfully, but these errors were encountered:
This sounds like an expected behaviour. You're setting day of the current week, so it can be both in the future and in the past.
Sorry, something went wrong.
A reliable way to do this would be:
function nextWeekday(date, weekday) { return date.plus({days: (7 - date.weekday + weekday) % 7}); }
I'll mark this as a feature request to potentially introduce DateTime#nextWeekday and DateTime#previousWeekday methods.
DateTime#nextWeekday
DateTime#previousWeekday
Hey @diesieben07 , can I raise a PR for this. Have added the suggested methods and respective tests.
Of course, go ahead @shashankbhat10
Duration.min()
Duration.max()
Successfully merging a pull request may close this issue.
Describe the bug
DateTime.set({ weekday: X }) sometimes returns a date in the past, and sometimes in the future.
To Reproduce
Actual vs Expected behavior
All values return a future date
Additional context
I think in moment.js, setting a weekday will always return a future date
The text was updated successfully, but these errors were encountered: