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.28k stars 510 forks source link

Interval >1 may skip a week #372

Open tim-phillips opened 4 years ago

tim-phillips commented 4 years ago

It appears that if dtstart is in the week before the first occurrence, then it will skip that occurrence, but if dtstart is in the same week then it will not. Any idea why this would be happening? Would be happy to open a PR.

import { RRule } from 'rrule'

const options = {
  freq: RRule.WEEKLY,
  interval: 2,
  count: 2,
  byweekday: [RRule.TU]
}

const rule1 = new RRule({
  ...options,
  dtstart: new Date(Date.UTC(2019, 10, 3))
})

const rule2 = new RRule({
  ...options,
  dtstart: new Date(Date.UTC(2019, 10, 4))
})

// rule1 and rule2 are across a week boundary
// rule1 results start a week later than rule2
console.log(rule1.all().map(toISOString))
console.log(rule2.all().map(toISOString))

function toISOString(d) {
  return d.toISOString()
}

https://codesandbox.io/s/rrule-interval-test-806pd

Expected output:

["2019-11-05T00:00:00.000Z", "2019-11-19T00:00:00.000Z"]
["2019-11-05T00:00:00.000Z", "2019-11-19T00:00:00.000Z"]

Actual output:

["2019-11-12T00:00:00.000Z", "2019-11-26T00:00:00.000Z"]
["2019-11-05T00:00:00.000Z", "2019-11-19T00:00:00.000Z"]

rrule@2.6.2 macOS 10.14.6 PDT

FaberM commented 4 years ago

I'm getting the same thing

qweluke commented 3 years ago

@FaberM @jakubroztocil any updates about this issue?