jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.34k stars 513 forks source link

byweekday does not work on second day #400

Open nmacherey opened 4 years ago

nmacherey commented 4 years ago

Hi,

I am playing with the demo and I do not see expected results when using multiple values in byweekday in combination with freq = MINUTELY and interval = 20 for example.

new RRule({
  freq: RRule.MINUTELY,
  dtstart: new Date(Date.UTC(2020, 4, 16, 9, 0, 0)),
  tzid: Europe/Brussels,
  count: 100,
  interval: 20,
  wkst: RRule.SU,
  byweekday: RRule.FR,
  byhour: [9, 10, 11, 12, 13, 14, 15, 16, 17],
  bysecond: [0]
})

Shows proper results (every 20 minutes between 9:00 and 17:00)

Capture d’écran 2020-05-16 à 16 16 56

But using

new RRule({
  freq: RRule.MINUTELY,
  dtstart: new Date(Date.UTC(2020, 4, 16, 9, 0, 0)),
  tzid: Europe/Brussels,
  count: 100,
  interval: 20,
  wkst: RRule.SU,
  byweekday: [RRule.MO, RRule.FR],
  byhour: [9, 10, 11, 12, 13, 14, 15, 16, 17],
  bysecond: [0]
})

Show proper values for Monday and only values between 15:00 and 17:00 for Fridays

Capture d’écran 2020-05-16 à 16 16 05
grant37 commented 4 years ago

Potentially similar to or same as #373, I think. I'm running into what appears to be the same thing. Here's my example:

rrule version: 2.6.4 os: macOS Mojave 10.14.6 local timezone: MDT

Code sample

const { RRule } = require('rrule');

const rule = new RRule({
  freq: RRule.MINUTELY,
  interval: 30,
  byweekday: [RRule.MO],
  dtstart: new Date(Date.UTC(2020, 7, 3)),
  until: new Date(Date.UTC(2020, 7, 20)),
  byhour: [14, 15, 16, 17]
});

rule.all(date => {
  console.log(date.toUTCString());
  return true;
});

Expected output

Mon, 03 Aug 2020 14:00:00 GMT
Mon, 03 Aug 2020 14:30:00 GMT
Mon, 03 Aug 2020 15:00:00 GMT
Mon, 03 Aug 2020 15:30:00 GMT
Mon, 03 Aug 2020 16:00:00 GMT
Mon, 03 Aug 2020 16:30:00 GMT
Mon, 03 Aug 2020 17:00:00 GMT
Mon, 03 Aug 2020 17:30:00 GMT
Mon, 10 Aug 2020 14:00:00 GMT
Mon, 10 Aug 2020 14:30:00 GMT
Mon, 10 Aug 2020 15:00:00 GMT
Mon, 10 Aug 2020 15:30:00 GMT
Mon, 10 Aug 2020 16:00:00 GMT
Mon, 10 Aug 2020 16:30:00 GMT
Mon, 10 Aug 2020 17:00:00 GMT
Mon, 10 Aug 2020 17:30:00 GMT
Mon, 17 Aug 2020 14:00:00 GMT
Mon, 17 Aug 2020 14:30:00 GMT
Mon, 17 Aug 2020 15:00:00 GMT
Mon, 17 Aug 2020 15:30:00 GMT
Mon, 17 Aug 2020 16:00:00 GMT
Mon, 17 Aug 2020 16:30:00 GMT
Mon, 17 Aug 2020 17:00:00 GMT
Mon, 17 Aug 2020 17:30:00 GMT

Actual output

Mon, 03 Aug 2020 14:00:00 GMT
Mon, 03 Aug 2020 14:30:00 GMT
Mon, 03 Aug 2020 15:00:00 GMT
Mon, 03 Aug 2020 15:30:00 GMT
Mon, 03 Aug 2020 16:00:00 GMT
Mon, 03 Aug 2020 16:30:00 GMT
Mon, 03 Aug 2020 17:00:00 GMT
Mon, 03 Aug 2020 17:30:00 GMT
Mon, 10 Aug 2020 16:00:00 GMT
Mon, 10 Aug 2020 16:30:00 GMT
Mon, 10 Aug 2020 17:00:00 GMT
Mon, 10 Aug 2020 17:30:00 GMT
Mon, 17 Aug 2020 16:00:00 GMT
Mon, 17 Aug 2020 16:30:00 GMT
Mon, 17 Aug 2020 17:00:00 GMT
Mon, 17 Aug 2020 17:30:00 GMT
grant37 commented 4 years ago

Locally I added the following test. Looks like some occurrences are skipped based on the third occurrence in the test output (those that should be on the 9th and 16th, I think). Seems similar to what happens in the examples.

  testRecurring('testMinutelyByWeekDayAndHour',
    new RRule({freq: RRule.MINUTELY,
      byweekday: RRule.TU,
      byhour: 9,
      interval: 30,
      dtstart: parse('19970902T090000'),
      count: 3
    }),
    [
      datetime(1997, 9, 2, 9, 0),
      datetime(1997, 9, 2, 9, 30),
      datetime(1997, 9, 9, 9, 0)
    ]
  )
  374 passing (2s)
  9 pending
  1 failing

  1) RRule
       testMinutelyByWeekDayAndHour [every 30 minutes for 3 times] [DTSTART:19970902T090000Z
RRULE:FREQ=MINUTELY;BYDAY=TU;BYHOUR=9;INTERVAL=30;COUNT=3]:

       - 3/3
      + expected - actual

      -Tue Sep 09 1997 03:00:00 GMT-0600 (Mountain Daylight Time)
      +Tue Sep 23 1997 03:00:00 GMT-0600 (Mountain Daylight Time)
seblemeur commented 3 years ago

Sorry for up, but did you found a solution? thx

JockeW commented 2 years ago

Did you found any solution to this?