Skip to content

Improvement: rule equivalent to BYSETPOS? #289

Open

Description

@k3rni

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.

Activity

  1. va7map commented on May 22, 2015

    @va7map

    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?

  2. avit commented on Jan 31, 2016

    @avit
    Collaborator

    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.

  3. davidstosik commented on Jan 4, 2019

    @davidstosik

    See #349 and #449.

  4. k3rni commented on Jan 4, 2019

    @k3rni
    Author

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

  5. regentgal commented on Feb 7, 2019

    @regentgal

    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?

  6. davidstosik commented on Feb 8, 2019

    @davidstosik

    @regentgal Sorry we made a mess with PRs...
    Here's more recent history: #468

    And a more recent PR, that is only in my fork at the moment: davidstosik#1

    I'd appreciate your review and input regarding the extra specs I added.

  7. gap777 commented on Sep 20, 2024

    @gap777

    We would greatly benefit from having this capability shipped... considering that PRs are opened, can we get those included?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions