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

Multi-day weekly recurring event misses first instance

Open papandreou opened this issue 8 years ago • 0 comments

I've run into a problem with weekly recurring events that happen on multiple days, where the first instance falls on a Sunday:

const icalJs = require('ical.js');
const vevent = new icalJs.Event(new icalJs.Component(icalJs.parse(`
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTART;VALUE=DATE:20170423
RRULE:FREQ=WEEKLY;BYDAY=SU,WE
SEQUENCE:0
SUMMARY:Recurring weekly on Sundays and Wednesdays
END:VEVENT
END:VCALENDAR
`)).getFirstSubcomponent('vevent'));
const iterator = vevent.iterator();

let next;
let num = 0;
while ((next = iterator.next()) && num++ < 5) {
    console.log(vevent.getOccurrenceDetails(next).startDate.toICALString());
}

Actual output:

20170426
20170430
20170503
20170507
20170510

Expected output (verified with Google Calendar and Apple's iCal):

20170423
20170426
20170430
20170503
20170507

It works if I add ;WKST=SU to the RRULE property, but that shouldn't be necessary. Also, the instance on April 23rd will be included if I change BYDAY=SU,WE to BYDAY=SU. So it's the presence of Wednesday in the set that throws ical.js off.

Perhaps related to: https://github.com/mozilla-comm/ical.js/issues/294

papandreou avatar Apr 05 '17 08:04 papandreou