I\'m creating a Rails app that will store the opening and closing hours for a business. Originally, I thought of simply using a text data type and letting it be free-form:
So I just found out ice_cube
can handle recurring durations:
> schedule = IceCube::Schedule.new(Time.now, :duration => 3600)
> schedule.add_recurrence_rule Rule.daily
> schedule.occurs_at?(Time.now + 1000)
true
> schedule.occurs_at?(Time.now + 1.day + 1000)
true
> schedule.occurs_at?(Time.now + 4000)
false
I suspect that you can handle a lot of different situations using ice_cube
in this manner.
Incidentally, I'm implementing a similar open/closed business schedule. I'd be interested to know how you've done it, and if you have a github repo we can collaborate on together.