rrule icon indicating copy to clipboard operation
rrule copied to clipboard

bysetpos with multiple byweekday in monthly recurrence giving unexpected results

Open VinitaPotter opened this issue 5 years ago • 6 comments
trafficstars

When the recurrence rule is set for every month on 3rd Monday and Wednesday, the resulting dates are messed up. Attaching a picture from the demo site.

new RRule({ freq: RRule.MONTHLY, count: 30, interval: 1, byweekday: [RRule.MO, RRule.WE], bysetpos: [3] })

String: RRULE:FREQ=MONTHLY;COUNT=30;INTERVAL=1;WKST=MO;BYDAY=MO,WE;BYSETPOS=3

But the resulting text and the result are incorrect

rule.toText(): every month on Monday, Wednesday for 30 times

expected rule.toText(): every month on 3rd Monday and Wednesday.

NOTE: bysetpos DOES work with one byweekday but not multiple days array in the demo site.

RRule bug

VinitaPotter avatar Nov 29 '19 09:11 VinitaPotter

Can confirm I'm seeing the same issue in my own implementation. Is the preference that we use the .nth method instead of trying to combine setpost and weekday?

Mattkins avatar Feb 10 '20 19:02 Mattkins

For anyone else looking here, I worked around this using the .nth method on the weekday constants.

rule.freq = RRule.MONTHLY
rule.byweekday = []
this.formGroup.value.byWeekDay.forEach((weekDay) => {
  this.formGroup.value.bySetPos.forEach((setPos) => {
    rule.byweekday.push(weekDay.nth(setPos))
  })
})

Mattkins avatar Feb 10 '20 19:02 Mattkins

@Mattkins where does the .nth() method come from?

tanthammar avatar Mar 18 '22 09:03 tanthammar

Hopefully I don't lead you on a wild goose chase, it's been a while and we don't work with this library any more. I believe it's on the weekday constants provided by RRule. For example:

const firstTuesday = RRule.TU.nth(1)

Mattkins avatar Mar 18 '22 18:03 Mattkins

Hopefully I don't lead you on a wild goose chase, it's been a while and we don't work with this library any more. I believe it's on the weekday constants provided by RRule. For example:

const firstTuesday = RRule.TU.nth(1)

Yes, I found it. Thank you for replying. May I ask which library you are using instead?

tanthammar avatar Mar 28 '22 10:03 tanthammar

@tanthammar, we don't do anything with rrule or any repeating dates any more, sorry.

Mattkins avatar Mar 28 '22 13:03 Mattkins