tickle icon indicating copy to clipboard operation
tickle copied to clipboard

The :now option doesn't seem to work very well

Open gampleman opened this issue 8 years ago • 2 comments

I have an app that supports cancelling the next occurrence of an event, but for this we need to calculate the next occurrence of the event for an event in the future, i.e.:

Time.now 
# => 2015-10-05 18:13:15 +0100
Tickle.parse('monday', now: Time.now)
# => {:next=>2015-10-12 12:00:00 +0100, :expression=>"monday", :starting=>2015-10-05 18:13:18 +0100, :until=>nil}
Tickle.parse('monday', now: Time.now + 1.day)
# => {:next=>2015-10-12 12:00:00 +0100, :expression=>"monday", :starting=>2015-10-05 18:13:26 +0100, :until=>nil}
Tickle.parse('monday', now: Time.parse('2015-10-12 12:00:00 +0100'))
# => {:next=>2015-10-12 12:00:00 +0100, :expression=>"monday", :starting=>2015-10-05 18:13:53 +0100, :until=>nil}
Tickle.parse('monday', now: Time.parse('2015-10-13 12:00:00 +0100'))
# => {:next=>2015-10-12 12:00:00 +0100, :expression=>"monday", :starting=>2015-10-05 18:14:37 +0100, :until=>nil}

gampleman avatar Oct 05 '15 17:10 gampleman

@gampleman

Yes, some of the options weren't being passed on properly before, the parsing code was a bit too complex so arguments were being silently ignored. In the develop branch there are new specs in the context "Given that now is in the future for this kind of thing that I hope work better. If the option isn't working for you when you use that branch, take a look at that block of specs and see if there's an example missing that would catch this, or if it's already been done. Then we can look at fixing the lib for you.

Regards, iain

yb66 avatar Oct 06 '15 04:10 yb66

Based on the specs it seems to work in the develop branch if also passing the same date with the :start option. Which is fine, albeit somewhat unintuitive.

gampleman avatar Oct 06 '15 09:10 gampleman