Fix timezones
Build Backend / build (push) Successful in 1m54s
Build Frontend / build (push) Successful in 3m43s

This commit is contained in:
2026-05-30 16:55:01 +02:00
parent 91184cfc96
commit 8852cf202e
6 changed files with 31 additions and 28 deletions
@@ -1,6 +1,6 @@
import { useMemo, useState, useEffect, Fragment } from 'react';
import { useStats } from '../../hooks/useStats';
import { timeToMinutes } from '../../utils/time';
import { timeToMinutes, adjustForTimezone } from '../../utils/time';
interface TimetableProps {
from_date: string;
@@ -106,8 +106,8 @@ const Timetable = ({ from_date, to_date, day_start, day_end }: TimetableProps) =
return timetable.slots.some((slot) => {
if (slot.date !== date || !slot.sleeping) return false;
const sStart = timeToMinutes(slot.slot_start);
const sEnd = timeToMinutes(slot.slot_end);
const sStart = adjustForTimezone(timeToMinutes(slot.slot_start));
const sEnd = adjustForTimezone(timeToMinutes(slot.slot_end));
if (sEnd <= sStart) {
const overlap1 = Math.max(sStart, intervalStart) < Math.min(1440, intervalEnd);
+5 -1
View File
@@ -68,7 +68,11 @@ export function formatElapsedTime(utcTimestamp: string): string {
* @returns formatted datetime string
*/
export function formatDateTime(date: Date | string): string {
const d = typeof date === 'string' ? new Date(date) : date;
let dateToParse = date;
if (typeof date === 'string' && !date.endsWith('Z') && !date.includes('+')) {
dateToParse = date + 'Z';
}
const d = typeof dateToParse === 'string' ? new Date(dateToParse) : dateToParse;
return d.toLocaleString('sv-SE', {
year: 'numeric',
month: '2-digit',