ice_cube icon indicating copy to clipboard operation
ice_cube copied to clipboard

Improvement: rule equivalent to BYSETPOS?

Open k3rni opened this issue 10 years ago • 7 comments

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):

  1. monthly.day_of_month(-1, -2, -3) and when ran, checking today's weekday
  2. 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.

k3rni avatar May 21 '15 13:05 k3rni

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?

va7map avatar May 22 '15 23:05 va7map

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.

avit avatar Jan 31 '16 04:01 avit

See #349 and #449.

davidstosik avatar Jan 04 '19 10:01 davidstosik

Excellent! Let's close this one once #449 lands.

k3rni avatar Jan 04 '19 15:01 k3rni

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 avatar Feb 07 '19 18:02 regentgal

@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.

davidstosik avatar Feb 08 '19 02:02 davidstosik