Are there ANY node ical libraries which can handle rrules and recurring events?
Opened this issue · 1 comments
Deleted user commented
For this demo calendar:
https://calendar.google.com/calendar/ical/ssjqjrg27h9mqqctfnr5kscmrk%40group.calendar.google.com/public/basic.ics
For calendar readers, the output looks like this:
But from this project, and its various forks, all I get is this:
On 2018-10-09, Event repeating monthly on 2nd tuesday at 10am
On 2018-10-10, Event repeating weekly on a Wednesday at 11am
On 2018-10-11, Single event on 11th October
Code is as below - a few extras as I'm not interested in dates in the past, and it's nice to have things in upcoming date order, rather than random
const ical = require('ical');
var dateNow = new Date();
const url = "https://calendar.google.com/calendar/ical/ssjqjrg27h9mqqctfnr5kscmrk%40group.calendar.google.com/public/basic.ics";
ical.fromURL(url, {}, function (err, data) {
var ttsorted = [];
for (const k in data) {
const ev = data[k];
const eventStart = new Date(ev.start);
if (data.hasOwnProperty(k)) {
if (eventStart.getTime() >= dateNow.getTime()) {
const tts = `On ${ev.start.toISOString().slice(0,10)}, ${ev.summary} `;
ttsorted.push(tts);
}
}
}
ttsorted.sort();
for (const events of ttsorted) {
console.log(events);
}
});
raineorshine commented
Looks like this has been at least partially implemented. I am able to get an array of recurrences (normal VEVENTs) by referencing master
instead of 0.5.0
(Commit #52c1d1c
at time of writing).
"dependencies": {
"ical": "git+https://github.com/peterbraden/ical.js.git#52c1d1c2b1ea3a74fb9254f0fc3f7a98503d3886"
}
Some additional work would need to be done to expand them out. Here is what it looks like:
{
...
recurrences: [ '2017-08-08': { type: 'VEVENT',
params: [],
start: { 2017-08-08T01:00:00.000Z tz: undefined },
end: { 2017-08-08T02:00:00.000Z tz: undefined },
dtstamp: { 2019-02-06T10:00:34.000Z tz: undefined },
uid: 'C0033A0A-2C38-4B9E-ABE6-47B29EC49CF4',
recurrenceid: { 2017-08-08T01:00:00.000Z tz: undefined },
created: { 2017-09-13T14:08:10.000Z tz: undefined },
description: '',
lastmodified: { 2018-08-20T19:04:14.000Z tz: undefined },
location: '',
sequence: '0',
status: 'CONFIRMED',
summary: 'My Event',
transparency: 'OPAQUE',
'APPLE-TRAVEL-ADVISORY-BEHAVIOR': 'AUTOMATIC' },
'2017-08-15': { type: 'VEVENT',
params: [],
start: { 2017-08-15T01:30:00.000Z tz: undefined },
end: { 2017-08-15T02:30:00.000Z tz: undefined },
dtstamp: { 2019-02-06T10:00:34.000Z tz: undefined },
uid: 'C0033A0A-2C38-4B9E-ABE6-47B29EC49CF4',
recurrenceid: { 2017-08-15T01:00:00.000Z tz: undefined },
created: { 2017-09-13T14:08:10.000Z tz: undefined },
description: '',
lastmodified: { 2018-08-20T19:04:14.000Z tz: undefined },
location: '',
sequence: '0',
status: 'CONFIRMED',
summary: 'My Event',
transparency: 'OPAQUE',
'APPLE-TRAVEL-ADVISORY-BEHAVIOR': 'AUTOMATIC' },
'2017-08-22': { type: 'VEVENT',
params: [],
start: { 2017-08-22T01:30:00.000Z tz: undefined },
end: { 2017-08-22T02:30:00.000Z tz: undefined },
dtstamp: { 2019-02-06T10:00:34.000Z tz: undefined },
uid: 'C0033A0A-2C38-4B9E-ABE6-47B29EC49CF4',
recurrenceid: { 2017-08-22T01:00:00.000Z tz: undefined },
created: { 2017-09-13T14:08:10.000Z tz: undefined },
description: '',
lastmodified: { 2018-08-20T19:04:14.000Z tz: undefined },
location: '',
sequence: '0',
status: 'CONFIRMED',
summary: 'My Event',
transparency: 'OPAQUE',
'APPLE-TRAVEL-ADVISORY-BEHAVIOR': 'AUTOMATIC' } ]
}
...
}