Reputation: 241
I'm using Google's RFC2445 implementation (http://code.google.com/p/google-rfc-2445/) for recurrence rules. If I define a MONTHLY recurrence starting on the 30th of January, months with less than 30 days (i.e., February) will be totally skipped. So the Google API would return 30th Jan, 30th March, 30th April, etc. Not good. I would expect it to return: 30th Jan, 28th Feb, 30th March, 30th April.
Similarly, if I picked a start date of the 31st of January, then any months with less than 31 days would be skipped.
This may be correct as per the RFC2445 spec or may be a bug. What do you think?
My main question is, is there any way to define a rule which says "recur on the 30th of every month; or the last day of the month if the 30th doesn't exist". I do not believe there is. Any suggestions?
Thanks in advance.
Regards, Cormac
Upvotes: 6
Views: 4879
Reputation: 131640
Well, looking at RFC 2445 itself it definitely seems that the behavior you're seeing is correct:
If BYxxx rule part values are found which are beyond the available scope (ie, BYMONTHDAY=30 in February), they are simply ignored.
The only solution I can think of is to use multiple recurrence rules, i.e. one for the 30th of every month and another for the last day in February.
Upvotes: 0
Reputation: 241
The answer is: FREQ=MONTHLY;BYMONTHDAY=28,29,30;BYSETPOS=-1 which translates to "recur on the 30th of every month; or the last day of the month if the 30th doesn't exist".
Upvotes: 18
Reputation: 110499
It looks like you're right about the RFC skipping those dates. If your DTSTART
is January 31, and you don't specify a BYMONTHDAY
in your recurrence rule (or if BYMONTHDAY
is on the 31st), then it'll simply ignore that rule in months where there is no such day:
If BYxxx rule part values are found which are beyond the available scope (ie, BYMONTHDAY=30 in February), they are simply ignored.
However, you should be able to specify -1 for BYMONTHDAY
and have it use the last day of the month, whatever it may happen to be.
The BYMONTHDAY rule part specifies a COMMA character (ASCII decimal 44) separated list of days of the month. Valid values are 1 to 31 or -31 to -1. For example, -10 represents the tenth to the last day of the month.
Upvotes: 0