Search code examples
icalendarrrulerfc5545

Express alternative recurring times in iCalendar


Is there a way to express the following in iCalendar? (possibly using RRULEs?)

Between 9am and 5pm every day except Sundays when it is between 10am and 4pm.

Can I create multiple RRULEs? Which ones have precedence?


Solution

  • iCalendar does not have a notion of events with a hole in the middle of the duration. So even without talking about recurring event, you can not create with a single event something like from 9AM to 10AM and from 4PM to 5 PM

    As a consequence, you need to actually create 3 events:

    DTSTART:2013xxxxT090000
    DURATION:PT1H
    RRULE:FREQ=DAILY
    
    DTSTART:2013xxxxT100000
    DURATION:PT6H
    RRULE:FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR,SA
    
    DTSTART:2013xxxxT160000
    DURATION:PT1H
    RRULE:FREQ=DAILY
    

    As far as having multiple RRULE, this was supported in RFC2445 but it has been deprecated in RFC5545 (just like EXRULE) due to lack of support and complexity.