Opening hours in ice_cube

回眸只為那壹抹淺笑 提交于 2019-12-06 08:33:01

问题


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)



来源:https://stackoverflow.com/questions/13496841/opening-hours-in-ice-cube

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!