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
- A rrule consists of multiple rules
- the FREQ rule is daily, weekly, monthly, yearly etc.
- INTERVAL - how the rule is applied (1 = every day, week etc.)
- UNTIL - when does it end or
- COUNT - how many events
- 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" - 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
- This seems to be page on page 116 of the rfc 2445 as well
- nothing to new
Lets do some testing directly with dateutil.rrule
- 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\'
- 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\' - 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.
- The following takes a rather long time:
In 24: list(rrule(DAILY,count=10,byweekday=(MO,TU),bysetpos=2))
Out24: [] - same with WEEKLY
- They only apply byweekday if bysetpos is also given. Does this make any sense?
- 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