rrule icon indicating copy to clipboard operation
rrule copied to clipboard

Interval >1 may skip a week

Open tim-phillips opened this issue 4 years ago • 2 comments

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"]

[email protected] macOS 10.14.6 PDT

tim-phillips avatar Nov 02 '19 03:11 tim-phillips

I'm getting the same thing

FaberM avatar Apr 07 '20 23:04 FaberM

@FaberM @jakubroztocil any updates about this issue?

qweluke avatar Nov 24 '20 11:11 qweluke