6

I am trying to create a rrule for my fullcalendar event, that occur on the 2nd Monday, Wednesday and Friday of the month for every month.

Here is the rrule I have tried

RRULE:FREQ=MONTHLY;COUNT=10;INTERVAL=1;WKST=SU;BYDAY=MO,WE,FR;BYSETPOS=2

events: [{
          title: 'rrule event',
          rrule: {
           freq: RRule.MONTHLY,
               count: 10,
               interval: 1,
               wkst: RRule.SU,
               byweekday: [RRule.MO, RRule.WE, RRule.FR],
               bysetpos: [2]
            },
            duration: '02:00',
        rendering: 'inverse-background'
         }
        ],

This is what I get

1   Fri,    03  May 2019    12:33:53    GMT
2   Wed,    05  Jun 2019    12:33:53    GMT
3   Wed,    03  Jul 2019    12:33:53    GMT
4   Mon,    05  Aug 2019    12:33:53    GMT
5   Wed,    04  Sep 2019    12:33:53    GMT
6   Fri,    04  Oct 2019    12:33:53    GMT
7   Mon,    04  Nov 2019    12:33:53    GMT
8   Wed,    04  Dec 2019    12:33:53    GMT
9   Fri,    03  Jan 2020    12:33:53    GMT
10  Wed,    05  Feb 2020    12:33:53    GMT

What is expected is

1    Mon,  08   Apr   2019
2    Wed,  10   Apr   2019
3    Fri,  12   Apr   2019
4    Mon,  13   May   2019
5    Wed,  08   May   2019  
6    Fri,  10   May   2019.........
Nash
  • 75
  • 6

1 Answers1

7

RFC 5545, section 3.3.10. states:

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

So the rule you're looking for literally specifies the 2nd Monday (2MO), Wednesday (2WE) and Friday (2FR) of each month.

FREQ=MONTHLY;COUNT=10;BYDAY=2MO,2WE,2FR (click to see the results)

Note that INTERVAL=1 is the default and WKST=SU is meaningless in this case, so you can just as well omit them.

Btw, your rule basically says, of all Mondays, Wednesdays and Fridays of a month, take the second instance in that month.

Community
  • 1
  • 1
Marten
  • 3,802
  • 1
  • 17
  • 26