diff --git a/js/calendar-events.js b/js/calendar-events.js
new file mode 100644
index 0000000..c4fc9ee
--- /dev/null
+++ b/js/calendar-events.js
@@ -0,0 +1,72 @@
+async function getCalendar(icalUrl) {
+  const response = await fetch(icalUrl);
+  const data = await response.text();
+  return data;
+}
+
+function getDateFromjCal(jCal, event, name) {
+  const date = event.getFirstPropertyValue(name);
+  const vtimezone = jCal.getFirstSubcomponent('vtimezone');
+  if (vtimezone && moment(date.toJSDate()).utcOffset()) {
+    date.zone = new ICAL.Timezone(vtimezone);
+  }
+  var locale = window.navigator.userLanguage || window.navigator.language;
+  moment.locale(locale);
+  return moment.parseZone(date.toJSDate()).utcOffset(date.utcOffset() / 60)
+};
+
+function insertCalendarEvents(dlElement, icalUrl, maxAgeDays = 1) {
+
+  if (!icalUrl) {
+    return;
+  }
+
+  getCalendar(icalUrl).then(data => {
+    // console.log(data);
+    var jcalData = ICAL.parse(data);
+    var vcalendar = new ICAL.Component(jcalData);
+    ICAL.helpers.updateTimezones(vcalendar, ICAL.TimezoneService);
+    const element = dlElement;
+
+    var events = vcalendar.getAllSubcomponents('vevent');
+    var eventArray = [];
+    var eventKeys = [];
+    var now = moment();
+    events.forEach(event => {
+      var start = getDateFromjCal(vcalendar, event, 'dtstart');
+      if (now.diff(start, 'days') <= maxAgeDays) {
+        var key = event.getFirstPropertyValue("dtstart") + "-" + event.getFirstPropertyValue("dtend");
+        eventArray[key] = event;
+        eventKeys.push(key);
+      }
+    });
+    dlElement.replaceChildren();
+    if (eventKeys.length == 0) {
+      const dd = document.createElement('dd');
+      dd.appendChild(document.createTextNode("–"));
+      element.appendChild(dd);
+      return;
+    }
+    eventKeys.sort().reverse().forEach(key => {
+      var event = eventArray[key];
+      var summary = event.getFirstPropertyValue('summary');
+      var start = getDateFromjCal(vcalendar, event, 'dtstart');
+      var end = getDateFromjCal(vcalendar, event, 'dtend');
+      const dt = document.createElement('dt');
+      const time = document.createElement('time');
+      dt.setAttribute('class', 'maintenance');
+      const node = document.createTextNode(start.format('dddd, LL'));
+      time.appendChild(node);
+      time.setAttribute('datetime', start.format('YYYY-MM-DD'));
+      dt.appendChild(time);
+      element.appendChild(dt);
+      const dd = document.createElement('dd');
+      const description = document.createTextNode(start.format("HH:mm") + "-" + end.format("HH:mm") + ` ${summary}`);
+      dd.appendChild(description);
+      element.appendChild(dd);
+    });
+  }
+  ).catch(error => {
+    console.log(error);
+  });
+}
