Hi, i've spent hours trying to figure out what am I doing wrong, but it looks like there's an issue with the library itself.
DTSTART:20190101T120000Z
RRULE:FREQ=WEEKLY
EXDATE:20190108T120000Z
@DeanOutlaw This is because EXDATE
is not an RRULE property. It is a top-level property (alongside, not nested under, RRULE). For example:
DTSTART:20190101T120000Z
RRULE:FREQ=WEEKLY
EXDATE:20190108T120000Z
How do I add an exdate then? dtstart is an rrule property on the rrule object. I do not want to use an rrule set - I should be able to do this just with toString() and fromString()
@stclairdaniel rrulejs is largely based on the iCal spec. dtstart
is an rrule property out of necessity. Many rrules can only be interpreted in the context of their dtstart.
For example,
DTSTART:20190101T120000Z
RRULE:FREQ=WEEKLY
What day of the week are occurrences on? The dtstart tells you.
In contrast, EXDATE does not affect the RRULE, it affects the VEVENT object. Technically, a VEVENT can have multiple RRULEs associated with it. The occurrences associated with the VEVENT are the distinct union of all the occurrences produced by its RRULEs, minus the occurrences produced by the EXRULEs, plus the RDATEs, minus the EXDATEs. In rrulejs, RRuleSet approximates the VEVENT recurrence logic.
I should be able to do this just with toString() and fromString()
Try the rrulestr
function on your ical fragment. You should get back an RRuleSet
object.
const str = `DTSTART:20190101T120000Z
RRULE:FREQ=WEEKLY
EXDATE:20190108T120000Z`;
const rruleset = rrulestr(str);
I do not want to use an rrule set
¯_(ツ)_/¯
freq: RRule.WEEKLY,
byweekday: [RRule.MO, RRule.FR],
dtstart: new Date(2021, 1, 1, 10, 30),
until: new Date(2021, 2, 2, 14, 30),
const tempExRule = new RRule({
freq: RRule.WEEKLY,
byweekday: [RRule.MO],
dtstart: new Date(2021, 1, 8, 10, 30),
until: new Date(2021, 1, 26, 14, 30),
const rule = new RRule(tempRule);
const ruleSet = new RRuleSet();
ruleSet.rrule(rule);
const exRule = new RRule(tempExRule);
const exRuleSet = new RRuleSet();
exRuleSet.rrule(tempExRule);
let arr1 = ruleSet.all().map((x) => JSON.stringify(x));
let arr2 = exRuleSet.all().map((x) => JSON.stringify(x))
let difference = arr1.filter((x) => !arr2.includes(x));
difference = difference.map((x) => new Date(x.slice(1, -1)));
console.log(difference)
I'm not sure if this is related but we seem to be having problems with exdate on OSX specifically. On windows and our linux environment there are no problems but on OSX we get rules.exdate is not a function
I am still getting this same error. In the js code I can see there is reference to exdate but when I use it in the tule string I receive the error listed above.