I am trying to parse an RRULE and display what weeks in the month a recurrence event is valid for. I have looked at the RFC2445 doc (http://www.ietf.org/rfc/rfc2445.txt) and it's not that clear.
I know for instance the rule:
RRULE FREQ=MONTHLY;INTERVAL=1;BYDAY=TH,FR,WE;BYSETPOS=10,11,12,7,8,9,1,2,3,4,5,6
Is for Wed, Thur, Friday on the 1st,2nd,3rd and 4th week of the month.
or
RRULE FREQ=MONTHLY;INTERVAL=1;BYDAY=TU,MO;BYSETPOS=3,4,5,6;
Is for Monday and Tuesday on the 2nd and 3rd week of the month.
or
RRULE FREQ=MONTHLY;INTERVAL=1;BYDAY=TH,WE;BYSETPOS=-1,-2
Is for Wed and Thursday on the last week of the month.
I generated these via another program, but am not sure how it actually generated them.
Thus the problem I am having is understanding how the BYSETPOS describes reoccurrence weeks for a month. The final goal is to be able to parse a RRULE such as the above and display at like so:
For: RRULE FREQ=MONTHLY;INTERVAL=1;BYDAY=TH,FR,WE;BYSETPOS=10,11,12,7,8,9,1,2,3,4,5,6
Show: Thur,Friday,Wed on week:1,2,3,4
For: RRULE FREQ=MONTHLY;INTERVAL=1;BYDAY=TU,MO;BYSETPOS=3,4,5,6;
Show: Tues, Monday on week:2,3
For: RRULE FREQ=MONTHLY;INTERVAL=1;BYDAY=TH,WE;BYSETPOS=-1,-2
Show: Whu,Wed on last week
The best solution would be a string in objective-c, but I can figure it out if it's another C like language. Even just a explanation of how BYSETPOS with BYDAY works would be great.