tags:

views:

447

answers:

2

I have been unsuccessful in formulating a RRULE that would allow an event as shown below:

Repeats YEARLY, from first Sunday of April to last day of May, occuring on Monday, Wednesday and Friday, until forever.

FREQ=YEARLY;BYMONTH=4;BYDAY=SU (gives me the first Sunday of April repeating yearly)

and

FREQ=YEARLY;BYMONTH=5;BYMONTHDAY=-1 (gives me the last day of May repeating yearly)

But I can't figure out how to have the event repeat yearly between those dates for Monday, Wednesday and Friday.

Suggestions?

Update: Comments don't have enough space to respond to Chris' answer, so I am editing the question with further information.

Unfortunately, no. I don't know if it is the DDay.iCal library I'm using, or what, but that doesn't work either. I've found that the date start can't be an ordinal date (first Sunday, etc.)..it has to be a specific date, which makes it difficult for my requirements. Even using multiple RRULE's it doesn't seem to work:

BEGIN:VCALENDAR 
VERSION:2.0 
PRODID:-//DDay.iCal//NONSGML ddaysoftware.com//EN 
BEGIN:VEVENT 
CREATED:20090717T033307Z 
DTSTAMP:20090717T033307Z 
DTSTART:20090101T000000 
RRULE:FREQ=YEARLY;WKST=SU;BYDAY=MO,WE,FR;BYMONTH=4,5 
RRULE:FREQ=YEARLY;WKST=SU;BYDAY=1SU;BYMONTH=4 
RRULE:FREQ=YEARLY;WKST=SU;BYMONTH=5;BYMONTHDAY=-1 
SEQUENCE:0 
UID:352ed9d4-04d0-4f06-a094-fab7165e5c74 
END:VEVENT 
END:VCALENDAR

That looks right on the face (I'm even starting the event on 1/1/2009), but when I start testing whether certain days are valid, I get incorrect results.

For example,

4/1/2009 12:00:00 AM = True   // Should be False
4/6/2009 12:00:00 AM = True  
4/7/2009 12:00:00 AM = False
4/8/2009 12:00:00 AM = True
5/1/2009 12:00:00 AM = True
5/2/2009 12:00:00 AM = False
5/29/2009 12:00:00 AM = True
5/31/2009 12:00:00 AM = True  // Should be False
6/1/2009 12:00:00 AM = False

I'm using Douglas Day's DDay.iCal software, but I don't think it is a bug in that library. I think this might be a limitation in iCalendar (RFC 2445).

Thoughts?

A: 

Try the BYMONTH rule to specify that you only want it in April and May:

RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=MO,WE,FR;BYMONTH=4,5;WKST=SU

This won't handle the "First Sunday of April" bit, which isn't in the MWF part of the pattern. I think this will be covered for the first occurrence if you set this specific date as your dtStart date (but of course, that won't recur for the next year by itself). Otherwise, I think you may need a second RRULE for that:

RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=4;WKST=SU

Does that help?

Chris Nielsen
A: 

Todd,

Using the 3 RRULEs as you have above will produce a union of results, not an intersection. You're right that there isn't a very graceful way in RFC2445/5545. However, if you have the ability to programatically calculate the first Sunday in April while you generate the event, the following should work:

DTSTART:20090405T000000
RRULE:FREQ=YEARLY;BYDAY=MO,WE,FR;UNTIL=20090531T000000Z

This method at least seems closer to what you were trying to achieve.

-Doug

Doug