How would you specify a rrule for an event on the 31st day of the month (or 30th, or 29th) that recurs every month, where if the month doesn't have enough days it picks the closest (i.e. for February it would pick the 28th or 29th, for April it would pick the 30th)?
Technically I'm using the rrule javascript library if that's relevant.
To add context, I have a form where the user can specify a start date an recurrence (yearly, monthly, weekly, daily), like for a bill. If a bill is usually due on the 30th then in February it will be due the 28th (or 29th).
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
:
FREQ=MONTHLY;BYMONTHDAY=28,29,30,31;BYSETPOS=-1
FREQ=MONTHLY;BYMONTHDAY=28,29,30;BYSETPOS=-1
FREQ=MONTHLY;BYMONTHDAY=28,29;BYSETPOS=-1
However, as one can see this is clearly more intuitive with RSCALE
.