Skip to content

Unable to understand 'BYSETPOS' in the Docs #89

Closed

Description

@marcoczen

Guys,

With reference to

rrule("FREQ=MONTHLY;INTERVAL=1;BYSETPOS=-1;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=13,14,15;COUNT=12")

I just cant seem to understand the purpose of 'bysetpos' ?
Anybody here can explain it ?

Thanks in advance ...

Activity

  1. boryn commented on Sep 17, 2021

    @boryn
    Contributor

    Hi @marcoczen!

    With the example of "FREQ=MONTHLY;INTERVAL=1;BYSETPOS=-1;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=26,27,28,29,30,31;COUNT=12"
    you have a set of occurences falling at 26-31 of the month and only on MO,TU,WE,TH,FR.

    BYSETPOS is not a rule by itself, actually it limits the rule. It means take the n-th instance from the calculated instances corresponding to the rest of the rule. So in our case it means take the last day at the end of the month of the working days.

    Hope it clarifies :)

  2. marcoczen commented on Sep 17, 2021

    @marcoczen
    Author

    Hi @boryn ,

    BYSETPOS is not a rule by itself, actually it limits the rule.

    Noted ...

    It means take the n-th instance from the calculated instances corresponding to the rest of the rule

    -1 ? nth instance ... but its not 2 or 3 or 1 but -1 ?
    Also, if i want the last of an occurence, its -1 ? Cant it be +366 or +365 ?

    Also bysetpos works on byday or bymonthday ? or both ?

    Sorry if i am a dumbass....

  3. marcoczen commented on Sep 17, 2021

    @marcoczen
    Author

    Background info for the next noob ...

    From https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.5

    The BYSETPOS rule part specifies a COMMA-separated list of values
    that corresponds to the nth occurrence within the set of
    recurrence instances specified by the rule. BYSETPOS operates on
    a set of recurrence instances in one interval of the recurrence
    rule. For example, in a WEEKLY rule, the interval would be one
    week A set of recurrence instances starts at the beginning of the
    interval defined by the FREQ rule part. 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:

       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 occurrences specified by the
      rule.
    
  4. Repository owner locked and limited conversation to collaborators on Sep 17, 2021
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions