mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-07 06:08:48 +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
|
@ -3,7 +3,7 @@ import { DateTime, Info } from "luxon";
|
|||
import classNames from "classnames";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Event from "./event";
|
||||
import Event, { compareDateTimezoneAware } from "./event";
|
||||
|
||||
const cellStyle = "relative w-10 flex items-center justify-center flex-col";
|
||||
const monthButton = "pl-6 pr-6 ml-2 mr-2 hover:bg-theme-100/20 dark:hover:bg-white/5 rounded-md cursor-pointer";
|
||||
|
@ -12,9 +12,7 @@ export function Day({ weekNumber, weekday, events, colorVariants, showDate, setS
|
|||
const currentDate = DateTime.now();
|
||||
|
||||
const cellDate = showDate.set({ weekday, weekNumber }).startOf("day");
|
||||
const filteredEvents = events?.filter(
|
||||
(event) => event.date?.startOf("day").toUnixInteger() === cellDate.toUnixInteger(),
|
||||
);
|
||||
const filteredEvents = events?.filter((event) => compareDateTimezoneAware(cellDate, event));
|
||||
|
||||
const dayStyles = (displayDate) => {
|
||||
let style = "h-9 ";
|
||||
|
@ -173,7 +171,7 @@ export default function Monthly({ service, colorVariants, events, showDate, setS
|
|||
|
||||
<div className="flex flex-col">
|
||||
{eventsArray
|
||||
?.filter((event) => showDate.startOf("day").ts === event.date?.startOf("day").ts)
|
||||
?.filter((event) => compareDateTimezoneAware(showDate, event))
|
||||
.slice(0, widget?.maxEvents ?? 10)
|
||||
.map((event) => (
|
||||
<Event
|
||||
|
@ -181,7 +179,7 @@ export default function Monthly({ service, colorVariants, events, showDate, setS
|
|||
event={event}
|
||||
colorVariants={colorVariants}
|
||||
showDateColumn={widget?.showTime ?? false}
|
||||
showTime={widget?.showTime && event.date.startOf("day").ts === showDate.startOf("day").ts}
|
||||
showTime={widget?.showTime && compareDateTimezoneAware(showDate, event)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue