ical: fix timezone issue, improve open-ended events
All checks were successful
publish / publish (push) Successful in 33s

This commit is contained in:
Lyn Fugmann 2024-10-07 19:16:49 +02:00
parent 33735268ff
commit 7284b97a8a

View file

@ -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}`,