Duration of occurrence over DST boundary needs to be an exception
I’ve got a three hour event scheduled every week from midnight to 3am Sunday morning, and another event scheduled from 3am to 6am every Sunday. I’m using durations of three hours each.
On March 13, the three hour event starting at midnight goes until 4am, causing a time conflict with the event starting at 3am. Is it possible for that one occurrence to be two hours long? Or to specify in some other way that it must end at 3am?
sunday = Time.new(2016, 1, 31, 0, 0, 0)
schedule = IceCube::Schedule.new(sunday, duration: 3600 * 3) do |s|
s.rrule(IceCube::Rule.weekly)
end
schedule.next_occurrences(8).map { |occurrence| occurrence.end_time.hour }
#=> [3, 3, 3, 3, 3, 3, 4, 3]
You can set an exception time (add_exception_time / extime) for your schedule, but there is no way to replace it with an occurrence of a different length. (Duration is global to the whole schedule.)
These occurrences still have the same duration, so they are technically valid. I don't think raising an exception applies.
What we could add is a method that tells you if the occurrence is affected by DST change. Something like this?
occurrence.dst_change? #=> true
occurrence.dst_change #=> 0 or -3600.0 or 3600.0
Depending on your circumstance you could subtract that from the end time. Would that work?