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

Use DTSTART when BY* is missing

Open radarfox opened this issue 5 years ago • 2 comments

Hello,

I think I have found the bug in this library, that has not been covered by any other issue here.

From the RFC 5545 3.3.10:

Information, not contained in the rule, necessary to determine the various recurrence instance start time and dates are derived from the Start Time ("DTSTART") component attribute. For example, "FREQ=YEARLY;BYMONTH=1" doesn't specify a specific day within the month or a time. This information would be the same as what is specified for "DTSTART".

... Then, lacking information from "RRULE", the second is derived from "DTSTART", to end up in "every Sunday in January at 8:30:00 AM and 9:30:00 AM, every other year". Similarly, if the BYMINUTE, BYHOUR, BYDAY, BYMONTHDAY, or BYMONTH rule part were missing, the appropriate minute, hour, day, or month would have been retrieved from the "DTSTART" property.

This isn't happening, at least with BYMONTH and BYMONTHDAY, as I have tested. The full list of BY* rules that should use this is: BYMONTH, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE and BYSECOND.

For example the following calendar has the single event. In this event the YEARLY frequency is defined and the day is second Friday, but the month is not explicitly mentioned. In this case, according to the RFC, the DTSTART should be used and the occurrences should be in August.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:+//IDN ki-wi.cz//NONSGML Player Lighter//EN
BEGIN:VEVENT
UID:91890
DTSTAMP:20191210T230600Z
DTSTART:20200814T000000
DTEND:20200814T120000
RRULE:FREQ=YEARLY;BYDAY=2FR
SUMMARY:event recurring yearly each 2nd Friday of August forever
END:VEVENT
END:VCALENDAR

I would expect the occurrences to be in August:

20200814T000000
20210813T000000
20220812T000000

But this isn't happening, the occurrences are in January:

20210108T000000
20220114T000000
20230113T000000

From these values I think it's clear, that ICAL.Recur is using January, when the BYMONTH is not explicitly defined. By this rule the first occurrence makes sense, the 20210108 is the 2nd Friday of January after 20200814.

If the BYMONTH is defined, then occurrences are as expected:

RRULE:FREQ=YEARLY;BYDAY=2FR;BYMONTH=8

radarfox avatar Apr 15 '20 19:04 radarfox

RRULE:FREQ=YEARLY;BYDAY=2FR means the second Friday in the year, see https://www.rfc-editor.org/errata/eid3779. Derivered from DTSTART are the hour and minutes, when the event starts, not the month.

dilyanpalauzov avatar Dec 24 '21 00:12 dilyanpalauzov

It should be derivered for BYMONTH. But you may be right, it shouldn't be derivered for BYDAY. Please, give me some time to investigate and provide a more detailed report.

radarfox avatar Jan 03 '22 10:01 radarfox

Just checking in on this, @radarfox have you had a chance to take a closer look if any additional action is needed here? Would also appreciate a retest on the latest version.

kewisch avatar May 01 '24 21:05 kewisch

It looks like we haven't heard back on this issue, therefore we are closing this issue. If this problem persists in the latest version of ical.js, please re-open this issue.

github-actions[bot] avatar Jun 01 '24 00:06 github-actions[bot]