From 17fe00d1232453687f73dbc430d78f44e472be4f Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 9 Apr 2026 18:01:56 +0400 Subject: [PATCH] start at 0 --- apps/web/src/dashboard/app.js | 2 +- apps/web/src/routes/dashboard.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/dashboard/app.js b/apps/web/src/dashboard/app.js index 2fe555c..40faea2 100644 --- a/apps/web/src/dashboard/app.js +++ b/apps/web/src/dashboard/app.js @@ -26,7 +26,7 @@ async function api(path, opts = {}) { } function formatAgo(ms) { - const s = Math.ceil(ms / 1000) || 1; + const s = Math.max(0, Math.ceil(ms / 1000)); if (s < 60) return `${s}s ago`; if (s < 3600) return `${Math.floor(s / 60)}m ago`; if (s < 86400)return `${Math.floor(s / 3600)}h ago`; diff --git a/apps/web/src/routes/dashboard.ts b/apps/web/src/routes/dashboard.ts index 9e28850..8304308 100644 --- a/apps/web/src/routes/dashboard.ts +++ b/apps/web/src/routes/dashboard.ts @@ -18,7 +18,7 @@ const eta = new Eta({ views: resolve(import.meta.dir, "../views"), cache: true, function timeAgoSSR(date: string | Date): string { const ts = new Date(date).getTime(); - const s = Math.ceil((Date.now() - ts) / 1000) || 1; + const s = Math.max(0, Math.ceil((Date.now() - ts) / 1000)); const text = s < 60 ? `${s}s ago` : s < 3600 ? `${Math.floor(s/60)}m ago` : s < 86400 ? `${Math.floor(s/3600)}h ago` : `${Math.floor(s/86400)}d ago`; return `${text}`; }