fix: treat naive backend timestamps as UTC for relative labels
Build / build (push) Successful in 10m35s

Backend emits store.Now() as "2026-04-23 14:05:32" — UTC but without a
Z marker or T separator. JavaScript parses such strings as local time,
so every "N ago" label is skewed by the browser's UTC offset (3h off
in UTC+3, causing the visible mismatch with the tooltip).

Normalise bare/space-separated timestamps to UTC inside toDate() so
every $fmt.* call, including relative, matches the absolute timestamp
shown in the tooltip. InstanceCard drops its own parser and delegates
to $fmt.relative for consistency.
This commit is contained in:
2026-04-23 14:39:41 +03:00
parent 90e6e59d9e
commit 03d58a072c
2 changed files with 20 additions and 12 deletions
+2 -11
View File
@@ -9,6 +9,7 @@
import ConfirmDialog from './ConfirmDialog.svelte';
import { IconPlay, IconStop, IconRestart, IconTrash, IconExternalLink, IconEvents } from '$lib/components/icons';
import { t } from '$lib/i18n';
import { fmt } from '$lib/format/datetime';
import * as api from '$lib/api';
interface Props {
@@ -31,17 +32,7 @@
: instance.subdomain ? `https://${instance.subdomain}` : ''
);
const timeSinceCreated = $derived(() => {
const created = new Date(instance.created_at);
const now = new Date();
const diffMs = now.getTime() - created.getTime();
const diffMins = Math.floor(diffMs / 60_000);
if (diffMins < 60) return `${diffMins}m ago`;
const diffHours = Math.floor(diffMins / 60);
if (diffHours < 24) return `${diffHours}h ago`;
const diffDays = Math.floor(diffHours / 24);
return `${diffDays}d ago`;
});
const timeSinceCreated = $derived(() => $fmt.relative(instance.created_at));
async function handleAction(action: 'stop' | 'start' | 'restart' | 'remove') {
loading = true;