Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bysetpos with multiple byweekday in monthly recurrence giving unexpected results #375

Open
VinitaPotter opened this issue Nov 29, 2019 · 6 comments

Comments

@VinitaPotter
Copy link

VinitaPotter commented Nov 29, 2019

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

@Mattkins
Copy link

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
Copy link

Mattkins commented Feb 10, 2020

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))
  })
})

@tanthammar
Copy link

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

@Mattkins
Copy link

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)

@tanthammar
Copy link

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?

@Mattkins
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants