-
Notifications
You must be signed in to change notification settings - Fork 116
/
example.js
22 lines (18 loc) · 852 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
// This example uses axios for requesting the calendar
// but is not required for use with ical.
const axios = require('axios');
const ical = require('ical');
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
axios.get('https://www.google.com/calendar/ical/en.usa%[email protected]/public/basic.ics')
.then(function (response) {
var data = ical.parseICS(response.data);
for (let k in data) {
if (data.hasOwnProperty(k)) {
var ev = data[k];
if (data[k].type == 'VEVENT') {
console.log(`${ev.summary} is in ${ev.location} on the ${ev.start.getDate()} of ${months[ev.start.getMonth()]} at ${ev.start.toLocaleTimeString('en-GB')}`);
}
}
}
});