ical.js
ical.js copied to clipboard
Iterator will generate events before the event starts
Admittedly I can also fix this in my calling code, so whether you'd like to accept it as a bug or not is entirely up to you:
https://github.com/mozilla-comm/ical.js/blob/master/lib/ical/event.js#L278-L283
This doesn't check whether the passed in startTime is before the dtstart, and happily generates events out of the original dtstart bounds, if asked to.
Can you please provide an (iCalendar) input, which is “interesting”?
VERSION:2.0
PRODID:-//www.contactoffice.com//NONSGML Calendar//EN
BEGIN:VTIMEZONE
TZID:Europe/London
X-TZINFO:Europe/London[2019c/Partial@9223372036854775807]
BEGIN:DAYLIGHT
TZOFFSETTO:+010000
TZOFFSETFROM:+000000
TZNAME:Europe/London(DST)
DTSTART:15320325T010000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETTO:+000000
TZOFFSETFROM:+010000
TZNAME:Europe/London(STD)
DTSTART:19971026T020000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP;VALUE=DATE-TIME:20201015T100822Z
LAST-MODIFIED:20201015T100519Z
DTSTART;TZID=Europe/London;VALUE=DATE-TIME:20201012T190000
DTEND;TZID=Europe/London;VALUE=DATE-TIME:20201012T230000
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,FR
EXDATE:20240412T180000Z
DESCRIPTION:In a pub or online
SUMMARY:Monday Board Games
LOCATION:Somewhere
UID:com_264201470
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
let component = new ICAL.Component(ICAL.parse(ical));
const vevents = component.getAllSubcomponents('vevent')
.filter((c) => !c.hasProperty('recurrence-id'))
.map((c) => new ICAL.Event(c, {'strictExceptions': true}));
// generate week starting october 5th
const start_date = Date(2020,9,5,19,0,0,0);
let iterator = vevents[0].iterator(ICAL.Time.fromJSDate(start_date));
Event (DTSTART) starts on Oct 12th, this generates one on Oct 5th
Perhaps label this issue as a bug?
This is still an issue and should be simple to fix. If a date is passed to iterator(), compare with this.startDate and take whatever is later in time. Double check if there can be cases where this.startDate is undefined.