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

Passing in integer for byweekday yields incorrect toText() #153

Closed
abrahamguo opened this issue Aug 5, 2016 · 3 comments
Closed

Passing in integer for byweekday yields incorrect toText() #153

abrahamguo opened this issue Aug 5, 2016 · 3 comments

Comments

@abrahamguo
Copy link

abrahamguo commented Aug 5, 2016

When integers are passed in to byweekday, toText() has strange behavior. The docs state that 0 == RRule.MO; however, toText parses 1 as Sunday, and fails entirely on 0:

var rrule0 = new RRule({
  freq: RRule.WEEKLY,
  byweekday: 0
});

// "every week"; should say "every week on Monday"
alert(rrule0.toText());

// "FREQ=WEEKLY;BYDAY=MO"
alert(rrule0.toString());

var rrule1 = new RRule({
  freq: RRule.WEEKLY,
  byweekday: 1
});

// "every week on Monday"; should be "every week on Tuesday"
alert(rrule1.toText());

// "FREQ=WEEKLY;BYDAY=TU"
alert(rrule1.toString());
@rustinlewis
Copy link

I'm getting the same bug. Has anyone be able to track this down?

@harrisi
Copy link
Contributor

harrisi commented Apr 12, 2018

The issue is with how this library handles numeric values representing days. I opened a pull request that fixes the "off-by-one" issue in the bottom half of this issue. The "every week" instead of "every week on Monday" is solved by changing byweekday: 0 to byweekday: RRule.MO. Hopefully I'll have a fix for this soon, as needing to use constants makes things really annoying.

@davidgoli
Copy link
Collaborator

This looks legitimate. 0 should be an acceptable substitute for RRule.MO as 1 is for RRule.TU.

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

4 participants