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

EXDATE not working if used together with RRULE in set #351

Open
pasevin opened this issue Jun 7, 2019 · 9 comments
Open

EXDATE not working if used together with RRULE in set #351

pasevin opened this issue Jun 7, 2019 · 9 comments

Comments

@pasevin
Copy link

pasevin commented Jun 7, 2019

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.

Bellow you can see my code snippet.
A few things to have in mind:

  • i tried to generate RRuleSet manually (same thing):
set.exdate(new Date(Date.UTC(2019, 5, 20, 0, 0)));
  • when i drop RRULE and instead use multiple RDATE, then EXDATE works!

My snippet:

const str = 'RRULE:FREQ=DAILY;UNTIL=20200630T000000\nEXDATE:20190619T000000'
const set: RRuleSet = rrulestr(str) as RRuleSet;
const rdates = set.all();
console.log(rdates);

Expected output:

Every single day except 2019-06-19

Actual output:

Every single day, with no exclusion...

Version of rrule:

2.6.0

Operatin system:

Mac OS

Local Timezone:

PDT

@DeanOutlaw
Copy link

Im having issues with trying to pass EXDATE in a rule.
I just get Error: Unknown RRULE property 'EXDATE'
This also happens on the demo when using the string input

@davidgoli
Copy link
Collaborator

@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

@pasevin
Copy link
Author

pasevin commented Jul 5, 2019

Yeah, this is not the same issue I have @DeanOutlaw @davidgoli

@ashishhrt
Copy link

Hi, interestingly if we use .all method before using EXDATE the exclusions don't work.
I'm not sure whether the library is using some catching mechanism to catch the result of .all operation.

@stclairdaniel
Copy link

@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()

@jorroll
Copy link

jorroll commented Aug 31, 2019

@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

¯_(ツ)_/¯

@mortocks
Copy link

mortocks commented Dec 4, 2020

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

@DanielBarbakadze
Copy link

use second RRuleSet() and get the difference.

 const tempRule = {
   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)

@jaredgibb
Copy link

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.

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

9 participants