Skip to content

Commit

Permalink
added parsing for alarms
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnytest1 committed Jan 31, 2024
1 parent 228ee19 commit 105647a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
21 changes: 12 additions & 9 deletions ical.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,15 +458,15 @@ module.exports = {
curr.end = moment.utc(curr.start).add(1, 'days').toDate(); // New Date(moment(curr.start).add(1, 'days'));
} else {
const durationUnits =
{
// Y: 'years',
// M: 'months',
W: 'weeks',
D: 'days',
H: 'hours',
M: 'minutes',
S: 'seconds'
};
{
// Y: 'years',
// M: 'months',
W: 'weeks',
D: 'days',
H: 'hours',
M: 'minutes',
S: 'seconds'
};
// Get the list of duration elements
const r = curr.duration.match(/-?\d+[YMWDHS]/g);
let newend = moment.utc(curr.start);
Expand Down Expand Up @@ -556,6 +556,9 @@ module.exports = {
if (typeof par[curr.uid].rrule !== 'undefined' && typeof par[curr.uid].recurrenceid !== 'undefined') {
delete par[curr.uid].recurrenceid;
}
} else if (component === 'VALARM' && par.type === 'VEVENT') {
par.alarms ??= [];
par.alarms.push(curr);
} else {
const id = uuid();
par[id] = curr;
Expand Down
7 changes: 5 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ vows
},
'task completed'(task) {
assert.equal(task.summary, 'Event with an alarm');
assert.equal(task.alarms?.length, 1);
}
}
},
Expand All @@ -318,7 +319,9 @@ vows
return ical.parseFile('./test10.ics');
},
'grabbing custom properties': {
topic() {}
topic() {
//
}
}
},

Expand Down Expand Up @@ -883,7 +886,7 @@ vows
topic() {
ical.fromURL('http://255.255.255.255/', {}, this.callback);
},
'are passed back to the callback'(error, result) {
'are passed back to the callback': (error, result) => {
assert.instanceOf(error, Error);
if (!error) {
console.log('>E:', error, result);
Expand Down

0 comments on commit 105647a

Please sign in to comment.