fix: use timezone offset for Now page

This commit is contained in:
Matej Stieranka 2025-07-01 13:26:48 +02:00
parent f1bcb761c0
commit ab957d6f87

View file

@ -163,15 +163,18 @@ export async function getNowEvents() {
} }
const now = new Date(); const now = new Date();
console.log("Offset:", now.getTimezoneOffset(), now.toISOString()); console.log("Offset:", now.getTimezoneOffset(), now.toISOString());
const offsetNow = new Date(
now.getTime() - now.getTimezoneOffset() * 60 * 1000,
);
return db return db
.select() .select()
.from(eventsTable) .from(eventsTable)
.where( .where(
and( and(
gte(eventsTable.startTime, now), gte(eventsTable.startTime, offsetNow),
lte( lte(
eventsTable.startTime, eventsTable.startTime,
new Date(now.getTime() + 2 * 60 * 60 * 1000), new Date(offsetNow.getTime() + 2 * 60 * 60 * 1000),
), ),
), ),
) )