jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.35k stars 513 forks source link

fromString returning incorrect options given simple recurrence string #389

Open JeffBaumgardt opened 4 years ago

JeffBaumgardt commented 4 years ago

When parsing a rule string using RRule.fromString an incorrect option is being returned.

When using a simple recurrence of RRULE:FREQ=WEEKLY I would expect the byweekday array in the options to be empty. However, it appears to populate with a random weekday number.

Please see console output for json objects

I have also tested with byday FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA and these are correctly listed. It's just when there is no BYDAY option in the string that's causing the issue.

Wycza commented 4 years ago

I encounter the same problem. When using fromString('RRULE:FREQ=WEEKLY;INTERVAL=1;WKST=MO') returned object contains byweekday: [6] which is Sunday (today day). It should not fill byweekday with any value.

dayre commented 3 years ago

Just discovered this today when trying to fromString a weekly rule interval 1. Workaround is to test the string prior, and add an empty array to get around the parseOptions code that adds the byweekday value.

var roptions = RRule.parseString(val)
if (val.indexOf("FREQ=WEEKLY") > 0 && val.indexOf("BYDAY") == -1) {
    roptions.byweekday = []
}
var rrule = new RRule(roptions)