mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-18 10:39:49 +00:00
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:
parent
674d7f2e01
commit
1f2081af5d
5 changed files with 23 additions and 14 deletions
|
@ -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",
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue