ical: fix timezone issue, improve open-ended events
All checks were successful
publish / publish (push) Successful in 33s
All checks were successful
publish / publish (push) Successful in 33s
This commit is contained in:
parent
33735268ff
commit
7284b97a8a
|
@ -3,10 +3,17 @@ import { ICalCalendar, ICalCalendarMethod } from 'ical-generator';
|
|||
export default class ProgramIcal {
|
||||
getDate(date, time) {
|
||||
const d = new Date(date);
|
||||
|
||||
if (time !== null) {
|
||||
const [ hours, mins ] = time.split(":");
|
||||
d.setHours(hours);
|
||||
d.setMinutes(mins);
|
||||
return d
|
||||
} 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}`,
|
||||
|
|
Loading…
Reference in a new issue