the start date cannot occur after the end date
dodomarocgenex opened this issue · 6 comments
In 2.0.0.rc1
Today being a Sunday, this
Tickle.parse("every other week starting this Sunday")
would generate this error:
/Users/UserName/.rvm/gems/ruby-2.4.0/gems/tickle-2.0.0.rc1/lib/tickle/tickle.rb:54:in `_parse': the start date (2017-03-19) cannot occur after the end date (Tickle::InvalidDateExpression)
from /Users/UserName/.rvm/gems/ruby-2.4.0/gems/tickle-2.0.0.rc1/lib/tickle.rb:42:in `parse'
from /Users/UserName/Desktop/file.rb:26:in `block in <top (required)>'
from /Users/UserName/Desktop/file.rb:25:in `each'
from /Users/UserName/Desktop/file.rb:25:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
I've pushed updates to the develop branch that should have fixed this. Passes the specs and Travis. Let me know if you get a chance to look at it.
iain
It works now.
Should "this Sunday" give the next Sunday if today is Sunday? (humanly speaking)
Good to hear.
That’s a very philosophical question! Chronic assures me it’s next Sunday. I think that without clarification most people would agree.
Chronic.parse "this Sunday"
# => 2017-03-19 12:00:00 +0000
Tickle.parse("every other week starting this Sunday")
# => {:next=>2017-03-19 12:00:00 +0000, :expression=>"other week", :starting=>2017-03-19 12:00:00 +0000, :until=>nil}
Tickle.parse("every other week starting today")
# => {:next=>2018-03-12 23:30:00 +0000, :expression=>"other week", :starting=>2018-03-12 23:30:00 +0000, :until=>nil}
I'm not really satisfied with these answers though - where's the repetition implied by "every other"? The last work I did on Tickle was a major clean up of the internals to move forward with things, I think I'll schedule that in soon (I know a major rewrite of Chronic is underway, might be a good time to look at what's happening).
Feel free to chime in with ideas if you think of any.
iain
Tickle.parse
should return another field: frequency.
and frequency is delicate in the human way of speaking. Consider these examples:
- Every second Thursday of September/each month.
- The last Friday of June of each year until 2020.
- Every Christmas from 1990 except the one on 2009
- Yearly on the 15th of April and August