Opening hours in ice_cube

2019-04-12 12:16发布

问题:

How am I able to rule opening hours of a restaurant within single Schedule?

Mon-Fri 8-16 is quite easy:

schedule = Schedule.new(Time.parse(Date.yesterday.to_s + ' 8:00'), :duration => 60*60*8)
(...)
schedule.add_recurrence_rule Rule.daily.day(:wednesday)
schedule.add_recurrence_rule Rule.daily.day(:thursday)
(...)
schedule.occurring_at?(Time.now)

Problem is when trying to rule something like: Mon 9-17, Tu 16-01 (the next day after midnight) etc.

Am I able to do this with that plugin?

回答1:

Just got email from an Ice_Cube author answering my question. Might be usefull:

Unfortunately we strive to maintain backwards compatibility with the iCalendar standard - so you can't change durations on a per-rule basis. If you want to accomplish something like the above, people either use multiple schedules, or store the durations separately (the latter is highly preferred)