kewisch / kewisch/ical.js

expanding repeating event with recurrence exception

Open
#285 4 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
1.2k
Forks
156
Avg merge
4d 43m
Merged PRs (30d)
3

Description

Hey :)

I need help (and would also like to suggest a helper function) to expand a repeating event with recurrence exceptions.
I'm testing this with version 1.2.2 (via bower).

#### Issue

The code below has a bug. Instead of 4 events, like expected, it creates 5 events.

Expected:
- Jan 3rd
- Jan 10th
- Jan 18th
- Jan 24th

Actual:
- Jan 3rd
- Jan 10th
- Jan 17th
- Jan 18th
- Jan 24th

I'd appreciate input how to get the expected result and I'd also be happy to help developing a helper function.
I have a similar issues for events with recurrence exceptions specifying `RANGE:THISANDFUTURE`

#### Code and example data
My current approach is the following:
```javascript
const vevents = context.comp.getAllSubcomponents('vevent');
vevents.forEach(function (vevent) {
const iCalEvent = new ICAL.Event(vevent);

if (!vevent.hasProperty('dtstart')) {
return;
}

// ...

if (iCalEvent.isRecurring()) {
// ...

let next;
while ((next = iterator.next())) {
// ...
// push event into some array
}
} else {
// ...
// push event into some array
}
});
```

Some example ics data:
```text/calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.12.2//EN
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
DTSTART:19810329T020000
TZNAME:GMT+2
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
DTSTART:19961027T030000
TZNAME:GMT+1
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20170119T180642Z
UID:99C096E7-0A03-48C2-B606-0BC558147842
RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=4
DTEND;TZID=Europe/Berlin:20170103T100000
TRANSP:OPAQUE
SUMMARY:test event
DTSTART;TZID=Europe/Berlin:20170103T090000
DTSTAMP:20170119T180700Z
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SEQUENCE:0
END:VEVENT
BEGIN:VEVENT
CREATED:20170119T180642Z
UID:99C096E7-0A03-48C2-B606-0BC558147842
DTEND;TZID=Europe/Berlin:20170118T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:test event
DTSTART;TZID=Europe/Berlin:20170118T090000
DTSTAMP:20170119T180706Z
SEQUENCE:0
RECURRENCE-ID;TZID=Europe/Berlin:20170117T090000
END:VEVENT
END:VCALENDAR
```

Contributor guide

Open the contributing guide

Research direction

Start with the ICAL.Event recurrence path shown in the example, especially isRecurring() and the iterator.next() loop, and reproduce the result using the supplied iCalendar data. Done means recurrence exceptions no longer produce the extra Jan 17 event, with the expected four dates returned; RANGE:THISANDFUTURE behavior is also noted as a related case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.