Rrule For Repeating Monthly On The 31st Or Closest Day
Solution 1:
There is a new extension to RRULE
called RSCALE
to cover that case. Unfortunately it's not widely supported yet. Not sure about the Javascript rrule library you're using, but you should open an issue if it's not the case.
Using the RSCALE
extension your RRULE
would look like so:
FREQ=MONTHLY;RSCALE=GREGORIAN;BYMONTHDAY=31;SKIP=BACKWARD
Events having this RRULE
recur on every 31st each month, unless that day doesn't exist in which case SKIP=BACKWARD
says "use the previous valid day".
Edit
I've just been made aware of another way to express this without RSCALE
:
31st each month with a fallback to the last valid day in that month:
FREQ=MONTHLY;BYMONTHDAY=28,29,30,31;BYSETPOS=-1
30th each month with a fall back to the 28th or 29th (in leap years) in February
FREQ=MONTHLY;BYMONTHDAY=28,29,30;BYSETPOS=-1
29th each month with a fall back to the 28th in February in non-leap years
FREQ=MONTHLY;BYMONTHDAY=28,29;BYSETPOS=-1
However, as one can see this is clearly more intuitive with RSCALE
.
Solution 2:
The simplest RRULE
to get "the last day of the month", regardless of whether it falls on the 28th, 29th, 30th, or 31st would be:
FREQ=MONTHLY;BYMONTHDAY=-1
Your query sounds like that's what you're after.
I don't know if this is supported by the rrule javascript library you mention, however.
Post a Comment for "Rrule For Repeating Monthly On The 31st Or Closest Day"