From 7284b97a8ae48cf15d081904b51638d4b22edcdf Mon Sep 17 00:00:00 2001 From: Lyn Fugmann Date: Mon, 7 Oct 2024 19:16:49 +0200 Subject: [PATCH] ical: fix timezone issue, improve open-ended events --- _includes/program-ical.11ty.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/_includes/program-ical.11ty.js b/_includes/program-ical.11ty.js index a6c7c8e..032e070 100644 --- a/_includes/program-ical.11ty.js +++ b/_includes/program-ical.11ty.js @@ -3,10 +3,17 @@ import { ICalCalendar, ICalCalendarMethod } from 'ical-generator'; export default class ProgramIcal { getDate(date, time) { const d = new Date(date); - const [ hours, mins ] = time.split(":"); - d.setHours(hours); - d.setMinutes(mins); - return d + + if (time !== null) { + const [ hours, mins ] = time.split(":"); + d.setHours(hours); + d.setMinutes(mins); + } else { + d.setDate(d.getDate() + 1); + d.setHours(0); + } + + return d.toISOString() } getLocalized(item, lang) { @@ -53,7 +60,7 @@ export default class ProgramIcal { start: this.getDate(date, event.start), end: ("end" in event && event.end !== null) ? this.getDate(date, event.end) - : this.getDate(date, "23:59"), + : this.getDate(date, null), summary: this.getLocalized(event.title, lang), description, url: `${url}/${lang}/program/#${id}`,