0

I'm trying to define a RRULE for an event which occurs on the first and second Monday and Tuesday of each month. This would equal four event occurrences per month. I thought this was correct:

FREQ=MONTHLY;INTERVAL=1;BYSETPOS=1,2;BYDAY=MO,TU

But it only generates occurrences for the first Monday/Tuesday of each month. If I remove Tuesday, it will generate occurrences for both the first and second Mondays in the month. Why can't I specify multiple BYSETPOS values (as the RRULE spec seems to allow) along with multiple BYDAY values?

How would such a rule be properly defined, as it's clear this is not the correct way?

Apparently I'm not understanding the BYSETPOS property clearly.
The doc linked above states:

bysetpos - If given, it must be either an integer, or a sequence of integers, positive or negative. Each given integer will specify an occurrence number, corresponding to the nth occurrence of the rule inside the frequency period. For example, a bysetpos of -1 if combined with a MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will result in the last work day of every month.

So I thought it was correct to use BYSETPOS to specify the desired occurrences within the frequency period (as a sequence of integers).

Thanks for your guidance.

Ryan Griggs
  • 2,457
  • 2
  • 35
  • 58

1 Answers1

1

How would such a rule be properly defined

Simply like this: BYDAY=1MO,1TU,2MO,2TU

Relevant quote from the RFC 5545:

  Each BYDAY value can also be preceded by a positive (+n) or
  negative (-n) integer.  If present, this indicates the nth
  occurrence of a 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.

Why can't I specify multiple BYSETPOS values (as the RRULE spec seems to allow) along with multiple BYDAY values?

You can - in fact you specified 2 with BYSETPOS=1,2. You asked for the 1st and 2nd results. But you want to get 4 occurrences per month (first Monday, first Tuesday, second Monday, second Tuesday), so you should specify 4 occurrences if you really wanted to use BYSETPOS : BYSETPOS=1,2,3,4. I do not recommend BYSETPOS though, BYDAY is much clearer and simpler to understand.

Community
  • 1
  • 1
rlanvin
  • 6,057
  • 2
  • 18
  • 24