2 Jun 2005 17:27

## Re: Questions regarding recurrence rules

```
Quoting reinhold <at> kainhofer.com, on Tue, May 31, 2005 at 03:59:12PM +0200:
> Hi Guys,
> I have few questions regarding details of recurrence rules of rfc 2445. (Sorry
> if I may sound more clueless than I really am. I have my assumptions, but I
> don't want to influence any answers by bringing too much of my own arguments
> and thoughts).

>   RRULE:FREQ=YEARLY;BYDAY=3SU
> Okay, that's the third sunday of the year. But what exactly is
>   RRULE:FREQ=YEARLY;BYDAY=5SU;BYMONTH=2
> Is this the fith sunday in the year, if it is also in february?

Yes.

Each BYDAY value can also be preceded by a positive (+n) or negative
(-n) integer. If present, this indicates the nth occurrence of the
specific day within the MONTHLY or YEARLY RRULE. For example, within
a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday
within the month, whereas -1MO represents the last Monday of the
month. If an integer modifier is not present, it means all days of
this type within the specified frequency. For example, within a
MONTHLY rule, MO represents all Mondays within the month.

Whether it is an offset within a month or year depends on the FREQ, not on the
presence of any other modifiers. This might be a common mistake, Apple's iCal
does this wrong, I've found.

RFC2445bis should add an example for this since its an area of confusion.

> Or is it the fifth sunday in february? And it can be even less clear

No.

> from rfc 2445. What is
>   RRULE:FREQ=YEARLY;BYDAY=5SU;BYMONTH=2,7
> Is this the fifth sunday of the year, if it's in either February or July?

Yes.

> Or is it the fifth sunday of both february and July?

No. That would be:

RRULE:FREQ=MONTHLY;BYDAY=5SU;BYMONTH=2,7

> Or is it the fifth sunday of febrary and july together (i.e. in feb if the feb
> in a leap year has 5 sundays, or the first sunday of july in all other
> years)?

No way!

> If you think it's the latter, think about the following rule:
>   RRULE:FREQ=YEARLY;BYWEEKNO=4;BYDAY=5SU

> Is it the fifth sunday of all sundays that are in week #4?

> Or is it the fifth sunday of the year if it is also in week #4?

Yes.

> Also, what does this rule mean:
>   RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU;BYYEARDAY=72

3rd month, and 2nd sunday in the year, and 72nd day in a year --> this won't
ever occur, of course.

> I suppose it doesn't mean the 72th day of the year, if that's the 2nd sunday
> in March. Is there any way to express that recurrence in an RRULE?

RRULE:FREQ=MONTHLY;BYMONTH=3;BYDAY=2SU;BYYEARDAY=72

> Also notice that rfc 2445 says "For example, within
>    a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday
>    within the month, whereas -1MO represents the last Monday of the
>    month. ". So what does
>   RRULE:FREQ=MONTHLY;BYYEARDAY=57,64;BYDAY=-1MO

Every month, the days that are the 57th&65th of the year (if in that month), and
that are on the last monday of the month.

> mean? The last monday of each month if it's also day #57 or #64 of the year
> (which the quote implies), or the last monday each month in the set of all
> days #57 and #64 of the year. In particular, in 2007, would the recurrence
> set be Feb 27 (=#57 of the year, and the last monday in february) without any
> occurence in march (march 5 is day #64, but it's not the last monday in the
> month, since rfc 2445 says -1MO means last monday of the month)? Or would it
> be Feb 27 (day #57 of the year, and last monday of all dates that match the
> BYYEARDAY in the february interval) and March 4 ( day #64 of the year and
> last monday of all dates in March that match the BYYEARDAY).
>
>
>
> 2) In Section 4.3.10 RFC 2445 says "The COUNT rule part defines the number of
> occurrences at which to range-bound the recurrence. The "DTSTART" property
> value, if specified, counts as the first occurrence.". So look at this rrule:
> DTSTART;TZID=whatever:20050530T120000
> RRULE:FREQ=WEEKLY;COUNT=3;BYMONTH=6

I'm sorry, I can't find where it says it right now to quote, but I have the
very distinct memory that RFC2445 says that the DTSTART property MUST specify a
time that is valid according to the RRULE.

So, the above combination of DTSTART and RRULE is invalid, it doesn't mean
anything.

One of the problem with the way the iCalendar series of RFCs are laid out is
they tend to describe each small part in isolation, but the parts have complex
interactions, and where these are described is semi-random and hard to find.

> 3) About the DTSTART and recurrence rules: Is the DTSTART always taken to
> match the rule (even if it doesn't fulfil the BY* parts)? In particular this
> is important for EXRULES: Is the DTSTART always the first occurence of the
> EXRULE? If that's the case, the DTSTART will always be excluded as soon as at
> least one EXRULE is present.
> And since exceptions overrule inclusions, there's no way to have an occurence
> on the DTSTART in that case... Is this really the intended behaviour?

I haven't implemented EXRULE (or ever seen one), but your argument that the
DTSTART will always be excluded looks right to me.

That sounds like it would be a problem, but section 4.8.5.2 says this:

The "EXRULE" property can be used to exclude the value specified in
^^^
"DTSTART". However, in such cases the original "DTSTART" date MUST
still be maintained by the calendaring and scheduling system because
the original "DTSTART" value has inherent usage dependencies by other
properties such as the "RECURRENCE-ID".

They say "can", maybe should say "would always"

It appears to me that DTSTART is made an exception, then, and must be kept.

So, don't make events whose alleged "start" is excluded from the set of events.
This actually seems reasonable, why not just start the event when it actually
starts?

Cheers,
Sam

```

Gmane