-
Notifications
You must be signed in to change notification settings - Fork 0
/
football.js
26 lines (24 loc) · 1.04 KB
/
football.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import ical from "node-ical"
const data = await ical.async.fromURL(
"https://ics.fixtur.es/v2/home/manchester-city.ics"
);
try {
for (let k in data) {
if (data.hasOwnProperty(k)) {
const event = data[k];
if (event.type == "VEVENT") {
if (new Date(event.start).setHours(0,0,0,0) == new Date().setHours(0,0,0,0)) {
const e = {
date: new Date(event.start).toLocaleDateString("en-GB"),
start: new Date(event.start).toLocaleTimeString(),
end: new Date(event.end).toLocaleTimeString(),
title: event.summary
};
console.log(`Notice! A football match is on today at the Etihad! \n **${e.title}** \n\n **Date:** ${e.date} \n **Start time:** ${e.start} \n **End time:** ${e.end} \n\n Roads and public transport will be extremely busy before and after the event, and on street parking will be extremely limited.`)
}
}
}
}
} catch (e) {
console.log(e);
}