Question

I'm trying to add event in the calendar programatically. I want the event to repeat yearly, every first Monday in February for example. The rule I'm using is this:

FREQ=YEARLY;BYDAY=1MO;BYMONTH=2;INTERVAL=1;COUNT=11;

The problem is: if I create the event with starting date in January and set it to repeat every January, then it works fine. But, If i create the event with starting date in other month other than February, and set it to repeat by the same rule, the event won't repeat on Monday but on some other day. That day is different depending in which month is the starting day of the event. It seems like it counts number of day because on the leap year the day is changed by one.

UPDATE:

I noticed that if I create an event as mentioned above the following happens: If I create the event for example in February and set to be repeated in March, the rule gets the number of days in month from the moth where the DTSTART of the event is set (February). So, if I create an event in February and set it to be repeated the last day in March it will be repeated every 28th March or 29th on leap years (instead of 31st as expected).

Another example: I create event with DTSTART in January 2013 and set it to be repeated every first Monday in February. It creates the event on the date in February 2013 that corresponds to the first Monday in January 2013, in this case that is 7th February (because 7th January is first Monday in January 2013). Every next year the event will be repeated on the first Thursday of February.

Was it helpful?

Solution

When adding the event DTSTART must be in the same month as the first occurrence of the event to avoid unwanted side effects

OTHER TIPS

can you give more details in terms of what you have and what you expect:

BEGIN:VCALENDAR
PRODID:byhand
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:20130205T090000Z
UID:SO_14702482_2b
SUMMARY:SO_14702482_2b
DTSTART:20130104T090000Z
RRULE:FREQ=YEARLY;BYDAY=1MO;BYMONTH=2;INTERVAL=1;COUNT=11;
END:VEVENT
END:VCALENDAR

will occur (tested on 2 different platforms) @09h00Z on: 20130104,20130204,20140203, 20150202,20160201, 20170206,...

while

BEGIN:VCALENDAR
PRODID:byhand
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:20130205T090000Z
UID:SO_14702482_1b
SUMMARY:SO_14702482_1b
DTSTART:20130204T090000Z
RRULE:FREQ=YEARLY;BYDAY=1MO;BYMONTH=2;INTERVAL=1;COUNT=11;
END:VEVENT
END:VCALENDAR

will occur (here also tested) @09h00Z on: 20130204, 20140203, 20150202,20160201, 20170206,...

the main difference being that as RFC5545 specified, DTSTART is part of the occurences.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top