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

Fix bug with weekday option not working as expected when shift is enabled #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shime
Copy link

@shime shime commented Nov 22, 2023

Hey Nando,

Thank you for the wonderful gem, we have been using it for years and it's really useful.

@pmrazovic has noticed a bug with how it handles weekday option when shift is enabled, so this PR fixes it.
We give users access to specify the rules for recurrence so we generally always want to enable shift.

Without the fix these are the first three Recurrence events for

r = Recurrence.new(every: :month, starts: "2011-01-31", on: "first", weekday: "monday", shift: true)
r.events
2011-02-07 ← first Monday of the month
2011-03-28 ← not the first Monday of the month
2011-09-26 ← not the first Monday of the month

This is with the fix:

2011-02-07 ←  first Monday of the month
2011-03-07 ←  first Monday of the month
2011-04-04 ←  first Monday of the month

@shime
Copy link
Author

shime commented Nov 22, 2023

Not sure why the tests are failing, I've tried updating the to_s(:date) references but that still didn't fix them, although it works locally™.

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

Successfully merging this pull request may close these issues.

1 participant