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

Iterator will generate events before the event starts #456

Open
castaway opened this issue Oct 20, 2020 · 4 comments
Open

Iterator will generate events before the event starts #456

castaway opened this issue Oct 20, 2020 · 4 comments

Comments

@castaway
Copy link
Contributor

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.

@dilyanpalauzov
Copy link
Contributor

Can you please provide an (iCalendar) input, which is “interesting”?

@castaway
Copy link
Contributor Author

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

@Zearin
Copy link
Contributor

Zearin commented Aug 29, 2022

Perhaps label this issue as a bug?

@kewisch
Copy link
Owner

kewisch commented May 14, 2024

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.

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

No branches or pull requests

4 participants