jkbrzt/rrule

Combining MINUTELY with BYHOUR and BYDAY misses out days when used with just one BYHOUR value

mfosker opened this issue · 0 comments

I may have misunderstood how to use this library, but am seeing fewer dates returned than I would expect for rRules such as :
FREQ=MINUTELY;INTERVAL=60;BYDAY=MO;BYHOUR=9

Originally I was setting up a schedule for an event that runs every 90 minutes between 09:00 to 17:00 using a rule like:
FREQ=MINUTELY;INTERVAL=90;BYDAY=MO,TU,WE,TH,FR;BYHOUR=9,10,11,12,13,14,15,16

Which seemed to work fine.
When I reduce the hours down to just '9' i.e at 9a.m I noticed that the number of results dropped massively, missing out entire weeks.

I've narrowed it down to a simple reproducible pair:
DTSTART:20230901T090000\nRRULE:FREQ=MINUTELY;INTERVAL=60;BYDAY=MO;BYHOUR=0,9;UNTIL=20231231T235900

Creates events at 00:00 and 09:00 every Monday from 1st Sept until the end of the year:

      2023-09-04T00:00:00.000Z, 2023-09-04T09:00:00.000Z,
      2023-09-11T00:00:00.000Z, 2023-09-11T09:00:00.000Z,
      2023-09-18T00:00:00.000Z, 2023-09-18T09:00:00.000Z,
      2023-09-25T00:00:00.000Z, 2023-09-25T09:00:00.000Z,
      2023-10-02T00:00:00.000Z, 2023-10-02T09:00:00.000Z,
      2023-10-09T00:00:00.000Z, 2023-10-09T09:00:00.000Z,
      2023-10-16T00:00:00.000Z, 2023-10-16T09:00:00.000Z,
      2023-10-23T00:00:00.000Z, 2023-10-23T09:00:00.000Z,
      2023-10-30T00:00:00.000Z, 2023-10-30T09:00:00.000Z,
      2023-11-06T00:00:00.000Z, 2023-11-06T09:00:00.000Z,
      2023-11-13T00:00:00.000Z, 2023-11-13T09:00:00.000Z,
      2023-11-20T00:00:00.000Z, 2023-11-20T09:00:00.000Z,
      2023-11-27T00:00:00.000Z, 2023-11-27T09:00:00.000Z,
      2023-12-04T00:00:00.000Z, 2023-12-04T09:00:00.000Z,
      2023-12-11T00:00:00.000Z, 2023-12-11T09:00:00.000Z,
      2023-12-18T00:00:00.000Z, 2023-12-18T09:00:00.000Z,
      2023-12-25T00:00:00.000Z, 2023-12-25T09:00:00.000Z
    ]

Removing just the 0, i.e having the event at just 09:00 :
DTSTART:20230901T090000\nRRULE:FREQ=MINUTELY;INTERVAL=60;BYDAY=MO;BYHOUR=9;UNTIL=20231231T235900

results in a far smaller list of events:

      2023-09-11T09:00:00.000Z,
      2023-10-02T09:00:00.000Z,
      2023-10-23T09:00:00.000Z,
      2023-11-13T09:00:00.000Z,
      2023-12-04T09:00:00.000Z,
      2023-12-25T09:00:00.000Z
    ]

This issue occurs whether I use the iCal style as shown above or if I construct the rRule using Javascript.

  freq: RRule.MINUTELY,
  dtstart: new Date(Date.UTC(2023, 8, 1, 9, 0, 0)),
  tzid: Europe/London,
  until: new Date(Date.UTC(2023, 11, 31, 21, 35, 0)),
  interval: 90,
  byweekday: RRule.MO,
  byhour: [0, 9]
})

works fine, but:

  freq: RRule.MINUTELY,
  dtstart: new Date(Date.UTC(2023, 8, 1, 9, 0, 0)),
  tzid: Europe/London,
  until: new Date(Date.UTC(2023, 11, 31, 21, 35, 0)),
  interval: 90,
  byweekday: RRule.MO,
  byhour: [9]
})

returns only 6 results.

I'm using rRule 2.2.9 and these results were observed in Jest tests on MacOS
Node v18.16.0

Currently it is BST where I am

Thanks for all your work on rRule