rossta / montrose

Recurring events library for Ruby. Enumerable recurrence objects and convenient chainable interface.

Home Page:https://rossta.net/montrose/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Daily recurrence skips 2 days on DST.

ricksuggs opened this issue · comments

Daily recurrence skips 2 days when starts is a local DateTime (ActiveSupport::TimeWithZone) with DST.

When the daily recurrence starts on a local DateTime (ActiveSupport::TimeWithZone) with DST between 2:00am and 2:59:59am, 2 days are skipped on "spring forward". Skipping one day may be reasonable, since the time officially switches over at 2:00am, but why would 2 days be skipped?

Example:

[4] pry(main)> r = Montrose.every(:day, at: '2:00:00', starts: DateTime.new(2024, 3, 8).in_time_zone('America/Los_Angeles'))
=> #<Montrose::Recurrence:2f684 {:every=>:day, :starts=>Thu, 07 Mar 2024 16:00:00.000000000 PST -08:00, :at=>[[2, 0, 0]]}>
[5] pry(main)> e = r.events.take(10)
=> [Fri, 08 Mar 2024 02:00:00.000000000 PST -08:00,
 Sat, 09 Mar 2024 02:00:00.000000000 PST -08:00,
 Tue, 12 Mar 2024 02:00:00.000000000 PDT -07:00,
 Wed, 13 Mar 2024 02:00:00.000000000 PDT -07:00,
 Thu, 14 Mar 2024 02:00:00.000000000 PDT -07:00,
 Fri, 15 Mar 2024 02:00:00.000000000 PDT -07:00,
 Sat, 16 Mar 2024 02:00:00.000000000 PDT -07:00,
 Sun, 17 Mar 2024 02:00:00.000000000 PDT -07:00,
 Mon, 18 Mar 2024 02:00:00.000000000 PDT -07:00,
 Tue, 19 Mar 2024 02:00:00.000000000 PDT -07:00]

Thanks for the report. I haven’t had a chance to look into this yet. PRs are welcome!