Fix timestamps off by timezone offset in non-UTC containers (#504)

All backend timestamps used datetime.now() (server local time) or the
deprecated datetime.utcnow(). The frontend's parseUTCDate() assumes
timestamps without timezone indicators are UTC and appends 'Z', so
stored timestamps were off by the timezone offset when the container's
timezone wasn't UTC.

Backend: replaced datetime.now() and datetime.utcnow() with
datetime.now(timezone.utc) across 16 files (~80 call sites) for all
database fields and DB comparisons. Cosmetic timestamps (filenames,
user-facing local time formatting) intentionally left as local time.

Frontend: replaced 13 new Date(backendTimestamp) calls with
parseUTCDate() across 8 files to correctly interpret UTC timestamps.
This commit is contained in:
maziggy
2026-02-24 08:18:02 +01:00
parent 974988c4f1
commit ed36eafbec
30 changed files with 207 additions and 203 deletions
+2 -1
View File
@@ -3,6 +3,7 @@
* These functions handle color normalization, slot labeling, and tray ID calculations
* for AMS, AMS-HT, and external spool configurations.
*/
import { parseUTCDate } from './date';
/**
* Normalize color format from various sources.
@@ -111,5 +112,5 @@ export function getMinDateTime(): string {
export function isPlaceholderDate(scheduledTime: string | null | undefined): boolean {
if (!scheduledTime) return false;
const sixMonthsFromNow = Date.now() + 180 * 24 * 60 * 60 * 1000;
return new Date(scheduledTime).getTime() > sixMonthsFromNow;
return (parseUTCDate(scheduledTime)?.getTime() ?? 0) > sixMonthsFromNow;
}