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 {
|
export default class ProgramIcal {
|
||||||
getDate(date, time) {
|
getDate(date, time) {
|
||||||
const d = new Date(date);
|
const d = new Date(date);
|
||||||
const [ hours, mins ] = time.split(":");
|
|
||||||
d.setHours(hours);
|
if (time !== null) {
|
||||||
d.setMinutes(mins);
|
const [ hours, mins ] = time.split(":");
|
||||||
return d
|
d.setHours(hours);
|
||||||
|
d.setMinutes(mins);
|
||||||
|
} else {
|
||||||
|
d.setDate(d.getDate() + 1);
|
||||||
|
d.setHours(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return d.toISOString()
|
||||||
}
|
}
|
||||||
|
|
||||||
getLocalized(item, lang) {
|
getLocalized(item, lang) {
|
||||||
|
@ -53,7 +60,7 @@ export default class ProgramIcal {
|
||||||
start: this.getDate(date, event.start),
|
start: this.getDate(date, event.start),
|
||||||
end: ("end" in event && event.end !== null)
|
end: ("end" in event && event.end !== null)
|
||||||
? this.getDate(date, event.end)
|
? this.getDate(date, event.end)
|
||||||
: this.getDate(date, "23:59"),
|
: this.getDate(date, null),
|
||||||
summary: this.getLocalized(event.title, lang),
|
summary: this.getLocalized(event.title, lang),
|
||||||
description,
|
description,
|
||||||
url: `${url}/${lang}/program/#${id}`,
|
url: `${url}/${lang}/program/#${id}`,
|
||||||
|
|
Loading…
Reference in a new issue