Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurrence expansion does not include DTSTART when not covered by the RRULE #294

Open
papandreou opened this issue Mar 7, 2017 · 4 comments
Labels

Comments

@papandreou
Copy link

papandreou commented Mar 7, 2017

I ran into this issue because the calendar app on newer iPads, probably mistakingly, allows the creation of an event where the start date is not covered by the RRULE. It's possible to create a recurring event that eg. starts on a Wednesday, but has a weekly recurrence rule of only Thursdays.

Apple's iCalendar application and Google Calendar both display that oddball first instance, but my application (which uses ical.js) does not.

The RFC5545 section about RRULE doesn't engrave in stone what's supposed to happen, but it does say (as part of the spec for COUNT in an RRULE):

The "DTSTART" property value always counts as the first occurrence.

... So I'm fairly certain that this is a bug in ical.js.

Here's a reduced test case:

const icalJs = require('ical.js');
const vevent = new icalJs.Event(new icalJs.Component(icalJs.parse(`
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
METHOD:REQUEST
VERSION:2.0
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20160920T065356Z
DTSTART:20170301T100000
DTEND:20170301T110000
RRULE:FREQ=WEEKLY;BYDAY=TH
SUMMARY:Happens every Thursday, but starts on a Wednesday
UID:C2366E0E-09A4-4B9C-B9F5-EE96CEE467F0
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());
}

Output:

20170302T100000
20170309T100000
20170316T100000
20170323T100000
20170330T100000

Expected output:

20170301T100000
20170302T100000
20170309T100000
20170316T100000
20170323T100000
@mifi
Copy link

mifi commented Mar 30, 2017

rrule has the same approach as ical.js, as well as python-dateutil.

From rrule:

Unlike documented in the RFC, the starting datetime, dtstart, is not the first recurrence instance, unless it does fit in the specified rules. This is in part due to this project being a port of python-dateutil, which has the same non-compliant functionality. Note that you can get the original behavior by using a RRuleSet and adding the dtstart as an rdate.

@papandreou
Copy link
Author

@mifi Hmm, nice find. Suggests that there might be an easy fix.

@mifi
Copy link

mifi commented Mar 30, 2017

Well the question is whether it is the responsibility of the recurrence iterator to add it, or if it's the responsibility of the developer using the library instead.

@papandreou
Copy link
Author

I'd say that it should be the responsibility of ical.js, as it's currently not in compliance with RFC5545.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants