Creating empty Biz::Schedule
pocman opened this issue · 7 comments
Hi,
before 1.6.0, I was using
Biz::Schedule.new do |config|
config.hours = {mon:{"00:00"=>"00:00"}}
config.breaks = {}
config.holidays = []
config.time_zone = "Europe/Paris"
end
but now, it leads to infinite loop when calling #within
on this Schedule.
Could you provide a simple way to generate an empty Schedule ?
Thanks for the report! I'll figure out what's going on when I have a bit of time.
@pocman This no longer works because we had to reject empty intervals to avoid an potential obscure DST bug.
Could you explain your use case more? Could you create a "null schedule" object that conforms to the biz
API instead?
@craiglittle that is exactly what I want : an empty (no hours) schedule that implement biz
api.
Biz::Schedule.empty
would be great. I thought it was possible to create an empty schedule using Biz::Schedule.new
!
Looking at it more, building this feature is going to introduce a decent amount of complexity for a small use case. I'm more inclined to throw a clearer error when you try to configure a schedule without any hours.
Instead of relying on biz
to generate a "null" schedule, why not create your own null object for your use case? Just have it always return zero when you call within
, right?
This isn't going to be behavior we're going to explicitly support at this time, but I'll keep an open mind if I hear similar use cases in the future. In the meantime, I'd suggest writing your own null object that fits your needs.
Thanks :-)
@craiglittle I also would like to have empty schedule for new users.
I think this is normal case, when new user register in application and has empty schedule and can configure it with UI in future.