Rrule: Using integers in byweekday causes javascripterror in toText()

Created on 16 Jul 2015  ·  9Comments  ·  Source: jakubroztocil/rrule

This works:

var options = {"freq":"1", "byweekday":RRule.TU};
var rule = new RRule(options);
console.log(rule.toText());

This does not work:

var options = {"freq":"1", "byweekday":1};
var rule = new RRule(options);
console.log(rule.toText());

When calling rule.toText() the following exception is thrown:
Uncaught TypeError: wday.getJsWeekday is not a function

http://jsfiddle.net/17b1at32/2/

Most helpful comment

I got this error today until I converted the array of WeekdayStr into ints

All 9 comments

+1 im still seeing this bug

I've just hit the same issue as well @michaelkrog is your fix suitable for a pull request into the main library?

(I appreciate this is quite an old issue for you at this point and you've probably moved on to other things!!)

+1 I'm facing the same issue.

Same issue here!

+1 still an issue: Uncaught TypeError: wday.getJsWeekday is not a function
Seems like there's activity again, maybe this will get fixed??

I found a way to work around this:

var myrule = {freq: RRule.weekly, byweekday: [1,2,3]}
// myrule.toText() -- this crashes.
var myrule2 = rrulestr(myrule.toString());
// myrule2.toText() -- this works.

It's a crappy solution though.

This appears fixed as of 2.3.4

I got this error today until I converted the array of WeekdayStr into ints

@strass Yes, effectively we need to use Weekday.fromStr(your string)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

espen picture espen  ·  11Comments

Prinzhorn picture Prinzhorn  ·  15Comments

spurreiter picture spurreiter  ·  3Comments

elazar picture elazar  ·  18Comments

shorlbeck picture shorlbeck  ·  21Comments