ice_cube
ice_cube copied to clipboard
Improvement: rule equivalent to BYSETPOS?
From RFC2445:
The BYSETPOS rule part specifies a COMMA character (US-ASCII decimal
44) separated list of values which corresponds to the nth occurrence
within the set of events specified by the rule. Valid values are 1 to
366 or -366 to -1. It MUST only be used in conjunction with another
BYxxx rule part. For example "the last work day of the month" could
be represented as:
RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
Each BYSETPOS value can include a positive (+n) or negative (-n)
integer. If present, this indicates the nth occurrence of the
specific occurrence within the set of events specified by the rule.
I don't think IceCube supports this right now. It would allow creating rules like the above "last work day of the month". Some ways to emulate this particular case are (as recurrence rules for Sidetiq jobs):
monthly.day_of_month(-1, -2, -3)and when ran, checking today's weekday- same, but excluding
daily.day(:saturday, :sunday). Not much better, can still occur more then once a month, when none of the last three days fall on a weekend.
Calling that hypothetical new rule indexed for now, one could write monthly.day(:monday, :tuesday, :wednesday, :thursday, :friday).indexed(-1). That rule would first evaluate to all weekdays in a month, and then restricted to the last one, whichever weekday that would be.
One of our projects uses ice_cube. Because BYSETPOS is not implemented, when expanding repeating events that uses it, extra instances get created. In @k3rni's example, an instance will be created for every single weekday of the month, rather than only the last weekday of the month.
Is this still on the to-do list?
In many cases it's possible to emulate this with multiple rules that "mask" the available occurrences. This might make more sense though, I'll leave it open for consideration, but I'm not sure when I can get to it.
See #349 and #449.
Excellent! Let's close this one once #449 lands.
Hi! There are two PRs outstanding for quite some time to add this functionality. My team would really like to see this added and released. How can we help?
@regentgal Sorry we made a mess with PRs... Here's more recent history: https://github.com/seejohnrun/ice_cube/pull/468
And a more recent PR, that is only in my fork at the moment: https://github.com/davidstosik/ice_cube/pull/1
I'd appreciate your review and input regarding the extra specs I added.