I'm reading through RFC 5545 and trying to determine how to correctly find a set of occurrences. Let's say I have a WEEKLY rrule = 2 (every other week). I also have specified a BYDAY rule part for Tue, Wed, Thu. Let's assume my start date is 2011-04-07 (Thu) and my end date is 2011-04-27 (Wed). Obviously ignoring less significant than date, I would think my occurrence set would contain: 2011-04-07, 2011-04-12, 2011-04-13, 2011-04-21, 2011-04-26, 2011-04-27.
What is throwing me off is this statement from the RFC: "The WKST rule part specifies the day on which the workweek starts. Valid values are MO, TU, WE, TH, FR, SA, and SU. This is significant when a WEEKLY "RRULE" has an interval greater than 1, and a BYDAY rule part is specified."
So, if my WKST=MO, I'm seeing an implication from the above statement that the week does not start from the start date, but from the WKST. Which means that instead of using a week based off of the start date, in this case, Thu-Wed, I need to actually start with WKST and determine which occurrences fall within THAT week (Mon-Sun) and every other week from THAT WKST. So, for calculation purposes, my starting date would actually be 2011-04-04. That falls before the start date so I jump ahead TO the start date but I stick with a Mon-Sun week. Which means my occurrence set is actually: 2011-04-07, 2011-04-19, 2011-04-20, 2011-04-21. That is vastly different than my original set.
Additionally, IF this is the proper way to calculate, does that also mean in expanding rrule situations for other frequencies with >1 intervals I must "start" at the beginning of that period instead of the start date. Does MONTHLY encompass the 1st - last day of the month of the start date开发者_StackOverflow. Does YEARLY encompass Jan 1 - Dec 31 of the year of the start date?
I hope there's an iCalendar guru out there...I can't wrap my head around the logic here. Thanks.
UPDATE: I did create a few .ics files and import into google calendar. Assuming google is interpreting these correctly, I can confirm that having an expanding MONTHLY with INTERVAL>1 will use the 1st to last day of the month, NOT a month starting from the start date from the event. YEARLY rules work in the same manner, the year goes from Jan 1st-Dec 31st. Not what I originally expected but hopefully this can help someone else out.
I don't know whether I qualify as a guru, but I have certainly battled my way through all the RRULE's.
My understanding is that yes, aboslutely the weekly rule MUST start from the start of the week according to WKST (and then within that your startdate may chop off some dates).
So if you wanted your original set of dates, then you'd have to say WKST=TH !
If you trust that google has people who have figured it all out already, then one method to check your understanding is to handcode some ics files with these rules and import them into google calendar and see what dates google generates.
You may also find this table helpful for recurring rules - also at the bottom of the page in the footer are some links to ics resources.
http://icalevents.com/2447-need-to-know-the-possible-combinations-for-repeating-dates-an-ical-cheatsheet/
精彩评论