rossta / montrose

Recurring events library for Ruby. Enumerable recurrence objects and convenient chainable interface.
https://rossta.net/montrose/
MIT License
821 stars 53 forks source link

Make During rule work for time range spanning midnight #138

Closed rossta closed 3 years ago

rossta commented 3 years ago

Previously, a recurrence with a during rule that spans overnight would not return expected results.

Now:

r = Montrose.hourly.during('11pm-3am').starts(Time.now).until(Time.now + 1.day)
=> #<Montrose::Recurrence:708 {:every=>:hour, :starts=>2021-02-03 21:21:01 -0500, :until=>2021-02-04 21:21:01 -0500, :during=>[[[23, 0, 0], [23, 59, 59]], [[0, 0, 0], [3, 0, 0]]]}>
r.events.to_a
=> [
 2021-02-03 23:21:01 -0500, 
 2021-02-04 00:21:01 -0500, 
 2021-02-04 01:21:01 -0500, 
 2021-02-04 02:21:01 -0500
]

Fixes #124