Home

what are rrules (hint: they are part of the icalendar standard)

Updated:
Created:

I'd like to understand the vs.event recurrence tab, and the settings in there. When looking at the source, some dateutil.rrule is important. But what is it?

vs.event imports dateutil.rrule. Dateutil is located at http://labix.org/python-dateutil

This hints to ftp://ftp.rfc-editor.org/in-notes/rfc2445.txt

In there the section on RRULE (page 39) seems to be important

  1. A rrule consists of multiple rules
  2. the FREQ rule is daily, weekly, monthly, yearly etc.
  3. INTERVAL -  how the rule is applied (1 = every day, week etc.)
  4. UNTIL - when does it end or
  5. COUNT - how many events
  6. BYXXX rules specify valid occurences within their specific logic. This whole section is rather long. Good example:

    "FREQ=DAILY;BYMONTH=1" reduces the number of recurrenceinstances from all days (if BYMONTH tag is not present) to all days in January"
  7. BYSETPOS seems apply a filter to a BYXXX rule, by defining valid occurrences.

    For example "the last work day of the month" could be represented as:

    RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1

    Not 100% sure if I can explain this correctly.

There seems to be more info on http://www.kanzaki.com/docs/ical/rrule.html

  1. This seems to be page on page 116  of the rfc 2445 as well
  2. nothing to new

Lets do some testing directly with dateutil.rrule

  1. without bysetpos:
    In 53: d.strftime(\'%c\') for d in  list(rrule(MONTHLY,count=10,byweekday=(MO,TU)))Out53:
    \'Mon Jul 26 16:06:27 2010\',\ \'Tue Jul 27 16:06:27 2010\',\ \'Mon Aug  2 16:06:27 2010\',\ \'Tue Aug  3 16:06:27 2010\',\ \'Mon Aug  9 16:06:27 2010\',\ \'Tue Aug 10 16:06:27 2010\',\ \'Mon Aug 16 16:06:27 2010\',\ \'Tue Aug 17 16:06:27 2010\',\ \'Mon Aug 23 16:06:27 2010\',\ \'Tue Aug 24 16:06:27 2010\'


  2. with bysetpos

    In 54: d.strftime(\'%c\') for d in  list(rrule(MONTHLY,count=10,byweekday=(MO,TU),bysetpos=2))Out54:
    \'Tue Aug  3 16:07:45 2010\',\ \'Tue Sep  7 16:07:45 2010\',\ \'Tue Oct  5 16:07:45 2010\',\ \'Tue Nov  2 16:07:45 2010\',\ \'Tue Dec  7 16:07:45 2010\',\ \'Tue Jan  4 16:07:45 2011\',\ \'Mon Feb  7 16:07:45 2011\',\ \'Mon Mar  7 16:07:45 2011\',\ \'Tue Apr  5 16:07:45 2011\',\ \'Tue May  3 16:07:45 2011\'
  3. From what I get from that is that I get a rough idea, but still can't 100% describe it. So maybe chuck this feature?

I am looking at the source code of vs.event.content.recurrency, and see that either byweekday and bysetpos are both applied, or none. Which we happen to do in the examples above.

  1. The following takes a rather long time:

    In 24: list(rrule(DAILY,count=10,byweekday=(MO,TU),bysetpos=2))
    Out24: []
  2. same with WEEKLY
  3. They only apply byweekday if bysetpos is also given. Does this make any sense?
  4. I think it would be best to apply byweekday if it has at least one element, and never bysetpos, because it risks breaking things

 

PS:

Apple has some info on http://developer.apple.com/iphone/library/documentation/DataManagement/Conceptual/EventKitProgGuide/CreatingRecurringEvents/CreatingRecurringEvents.html. This means that the standard is approved as such by the church