iCalendar: MONTHLY RRULE without BYDAY or BYMONTHDAY

1k Views Asked by At

How to interpret a monthly recurrence rule with only DTSTART (no BYDAY or BYMONTHDAY)?

According to RFC5545 you can define a recurrence rule with a frequency only, for example

DTSTART;TZID=US-Eastern:20180831T090000
RRULE:FREQ=MONTHLY

A smartphone with LineageOG (Android Calendar) apparently interprets this as BYMONTHDAY and shows the event only if there is a 31st of a month. An iPhone apparently interprets this as the last day of the month and shows the event each month (31st, 30th or even 28th). Which interpretation is correct?

2

There are 2 best solutions below

0
anmari On

Arguably iPhone is ‘wrong’ although the rfc5545 doesn’t explicitly address that issue https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html

Perhaps they have taken a ‘what would the non technical user expect ?’ approach?

Thinking Apple are wrong doesn’t help. It would be better to generate an RRULE that is explicitly clear. Use the BYMONTHDAY if only want 31st, or use the BYDAY=-1for the last day of month

0
Marten On

The iPhone is definitely wrong here. RFC 5545, section 3.3.10 clearly states:

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".

and

Recurrence rules may generate recurrence instances with an invalid date (e.g., February 30) or nonexistent local time (e.g., 1:30 AM on a day where the local time is moved forward by an hour at 1:00 AM). Such recurrence instances MUST be ignored and MUST NOT be counted as part of the recurrence set.

These two taken together means your event recurs on every 31st, but only in months which actually have 31 days, otherwise the instance is ignored.

Either way, it's indeed better to be explicit about the intent and always provide BYMONTHDAY in such case.