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

Except: Date.today not working #19

Open
anlek opened this issue Dec 12, 2014 · 1 comment
Open

Except: Date.today not working #19

anlek opened this issue Dec 12, 2014 · 1 comment

Comments

@anlek
Copy link

anlek commented Dec 12, 2014

As far as I can tell, except doesn't work with Date.today (Even if it's a string, or inside an array)

r = Recurrence.new(every: :month, on: Date.today.day, interval: 1, except: Date.today)
r.next == Date.today # => true

Let me know if you need any more info

@fnando
Copy link
Owner

fnando commented Feb 22, 2021

It's been a long time, sorry for never answering this issue.

The way you can handle this is by ensuring you're always calling next! before next. The issue here is that we use Date.today as the starting point and next doesn't do anything other than return whatever the current date for that event is.

If you try something like below, you can see that the dates are correctly calculated.

r = Recurrence.new(every: :month, on: Date.today.day, interval: 1,
                       until: 3.months.from_now.to_date,
                       except: Date.today)
p r.each
#=> #<Enumerator: [Mon, 22 Mar 2021, Thu, 22 Apr 2021, Sat, 22 May 2021]:each>

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

No branches or pull requests

2 participants