rrule
rrule copied to clipboard
bysetpos with multiple byweekday in monthly recurrence giving unexpected results
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.

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?
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 where does the .nth() method come from?
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)
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, we don't do anything with rrule or any repeating dates any more, sorry.