Fix false stale Fleet reports caused by clock skew
This commit is contained in:
@@ -54,9 +54,9 @@
|
||||
mapLabelOverride
|
||||
}: Props = $props();
|
||||
|
||||
function ago(iso: string | null): string {
|
||||
function ago(iso: string | null, now: number): string {
|
||||
if (!iso) return 'never';
|
||||
const d = Date.now() - new Date(iso).getTime();
|
||||
const d = now - new Date(iso).getTime();
|
||||
if (d < 60_000) return `${Math.max(1, Math.floor(d / 1000))}s ago`;
|
||||
if (d < 3_600_000) return `${Math.floor(d / 60_000)}m ago`;
|
||||
if (d < 86_400_000) return `${Math.floor(d / 3_600_000)}h ago`;
|
||||
@@ -175,9 +175,9 @@
|
||||
{#if health === 'offline' && lastError}
|
||||
<span class="err">{lastError}</span>
|
||||
{:else if lastSeenAt}
|
||||
<span>Last seen {ago(lastSeenAt)}</span>
|
||||
<span>Last seen {ago(lastSeenAt, $uiNow)}</span>
|
||||
{:else if lastRestartedAt}
|
||||
<span>Restart {ago(lastRestartedAt)}</span>
|
||||
<span>Restart {ago(lastRestartedAt, $uiNow)}</span>
|
||||
{:else}
|
||||
<span class="dim">No data</span>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user