ical.js icon indicating copy to clipboard operation
ical.js copied to clipboard

Wrong First Occurrence for MONTHLY rrule when BYDAY & BYSETPOS are present

Open arunpandianp opened this issue 8 years ago • 1 comments

recur = ICAL.Recur.fromData({
 freq:"MONTHLY",
 byday: ['SU'],
 bysetpos: [-1]
 }); // last sunday in every month
start = ICAL.Time.fromDateString("2017-07-01") //saturday
it = recur.iterator(start)
console.log('Expected 2017-07-30, Actual ' + it.next()); // it.next() is giving 2017-07-02  

looks like the recur_iterator's init which sets the first occurrence, has no logic for handling bysetpos

jsFiddle link: https://jsfiddle.net/ysg04wL5/1/

arunpandianp avatar Jul 03 '17 04:07 arunpandianp

I think this is actually on purpose. When iterating a recurrence rule, the first instance is given by DTSTART. If you pass a date that is not covered by the rule, it is still the first instance. What you'd need to do is pass in a start that is covered by the rule. Does this help?

kewisch avatar Oct 06 '19 12:10 kewisch