mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-22 03:49:18 +02:00
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:
@@ -23,6 +23,7 @@ import {
|
||||
Box,
|
||||
} from 'lucide-react';
|
||||
import { api } from '../api/client';
|
||||
import { parseUTCDate } from '../utils/date';
|
||||
import { Button } from './Button';
|
||||
import { ConfirmModal } from './ConfirmModal';
|
||||
import { ModelViewer } from './ModelViewer';
|
||||
@@ -561,13 +562,13 @@ export function FileManagerModal({ printerId, printerName, onClose }: FileManage
|
||||
case 'size-desc':
|
||||
return b.size - a.size;
|
||||
case 'date-asc': {
|
||||
const aTime = a.mtime ? new Date(a.mtime).getTime() : 0;
|
||||
const bTime = b.mtime ? new Date(b.mtime).getTime() : 0;
|
||||
const aTime = a.mtime ? parseUTCDate(a.mtime)?.getTime() ?? 0 : 0;
|
||||
const bTime = b.mtime ? parseUTCDate(b.mtime)?.getTime() ?? 0 : 0;
|
||||
return aTime - bTime;
|
||||
}
|
||||
case 'date-desc': {
|
||||
const aTime = a.mtime ? new Date(a.mtime).getTime() : 0;
|
||||
const bTime = b.mtime ? new Date(b.mtime).getTime() : 0;
|
||||
const aTime = a.mtime ? parseUTCDate(a.mtime)?.getTime() ?? 0 : 0;
|
||||
const bTime = b.mtime ? parseUTCDate(b.mtime)?.getTime() ?? 0 : 0;
|
||||
return bTime - aTime;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user