Allow clearing default order schedule
This commit is contained in:
parent
61a5314b95
commit
c1413ff817
4 changed files with 14 additions and 7 deletions
|
|
@ -1,13 +1,14 @@
|
|||
module FoodsoftDateUtil
|
||||
# find next occurence given a recurring ical string and time
|
||||
def self.next_occurrence(start=Time.now, from=start, options={})
|
||||
if options[:recurr]
|
||||
occ = nil
|
||||
if options && options[:recurr]
|
||||
schedule = IceCube::Schedule.new(start)
|
||||
schedule.add_recurrence_rule rule_from(options[:recurr])
|
||||
# @todo handle ical parse errors
|
||||
occ = (schedule.next_occurrence(from).to_time rescue nil)
|
||||
end
|
||||
if occ && options[:time]
|
||||
if options && options[:time] && occ
|
||||
occ = occ.beginning_of_day.advance(seconds: Time.parse(options[:time]).seconds_since_midnight)
|
||||
end
|
||||
occ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue