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

added parsing for alarms #299

Merged
merged 7 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.type === 'VTODO')) {
par.alarms ??= [];
par.alarms.push(curr);
} else {
const id = uuid();
par[id] = curr;
Expand Down
11 changes: 9 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ vows
},
'task completed'(task) {
assert.equal(task.summary, 'Event with an alarm');
assert.equal(task.alarms?.length, 1);
const alarm = task.alarms[0];
assert.equal(alarm.description, 'Reminder');
assert.equal(alarm.action, 'DISPLAY');
assert.equal(alarm.trigger.val, '-PT5M');
}
}
},
Expand All @@ -318,7 +323,9 @@ vows
return ical.parseFile('./test10.ics');
},
'grabbing custom properties': {
topic() {}
topic() {
//
}
}
},

Expand Down Expand Up @@ -883,7 +890,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
4 changes: 2 additions & 2 deletions test/test2.ics
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ DTSTAMP:20021028T011706Z
SUMMARY:Coffee with Jason
UID:EC9439B1-FF65-11D6-9973-003065F99D04
DTEND;TZID=US/Pacific:20021028T150000
END:VEVENT
BEGIN:VALARM
TRIGGER;VALUE=DURATION:-P1D
ACTION:DISPLAY
DESCRIPTION:Event reminder
END:VALARM
END:VEVENT
BEGIN:VEVENT
SEQUENCE:1
DTSTAMP:20021128T012034Z
Expand All @@ -43,7 +43,6 @@ ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:[email protected]
DUE:19980415T235959
STATUS:NEEDS-ACTION
SUMMARY:Submit Income Taxes
END:VTODO
BEGIN:VALARM
ACTION:AUDIO
TRIGGER:19980403T120000
Expand All @@ -52,6 +51,7 @@ ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio-
REPEAT:4
DURATION:PT1H
END:VALARM
END:VTODO
BEGIN:VJOURNAL
DTSTAMP:19970324T120000Z
UID:[email protected]
Expand Down
Loading