Skip to content

Improvement: rule equivalent to BYSETPOS? #289

@k3rni

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.

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