Add option to specify a timezone for events (#2623)

* Add option to specify a timezone for events

* Amend message, update docs
This commit is contained in:
Denis Papec 2024-01-15 02:01:10 +00:00 committed by GitHub
parent 674d7f2e01
commit 1f2081af5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 14 deletions

View file

@ -23,8 +23,9 @@ export default function Integration({ config, params, setEvents, hideErrors }) {
}
}
const startDate = DateTime.fromISO(params.start);
const endDate = DateTime.fromISO(params.end);
const zone = config?.timezone || null;
const startDate = DateTime.fromISO(params.start, { zone });
const endDate = DateTime.fromISO(params.end, { zone });
if (icalError || !parsedIcal || !startDate.isValid || !endDate.isValid) {
return;
@ -43,12 +44,15 @@ export default function Integration({ config, params, setEvents, hideErrors }) {
const duration = event.dtend.value - event.dtstart.value;
const days = duration / (1000 * 60 * 60 * 24);
const now = DateTime.now().setZone(zone);
const eventDate = DateTime.fromJSDate(date, { zone });
for (let j = 0; j < days; j += 1) {
eventsToAdd[`${event?.uid?.value}${i}${j}${type}`] = {
title,
date: DateTime.fromJSDate(date).plus({ days: j }),
date: eventDate.plus({ days: j }),
color: config?.color ?? "zinc",
isCompleted: DateTime.fromJSDate(date) < DateTime.now(),
isCompleted: eventDate < now,
additional: event.location?.value,
type: "ical",
};