From d1b90cfdcbb51de268b98edf2dc0843b9e891323 Mon Sep 17 00:00:00 2001 From: ookami125 Date: Wed, 24 Jun 2026 01:25:43 -0400 Subject: [PATCH] webui: fix relative timestamps (seconds, not milliseconds) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit f.date/f.ago assumed JS milliseconds, but the backend emits Unix epoch seconds everywhere (created_at, feed lastUpdate, rule lastMatch, …), so every real timestamp rendered as ~20607 days ago (now - ~1.78e9 ms). Treat the formatter input as seconds. Search results show the indexer's pubDate string directly rather than mis-parsing it. Co-Authored-By: Claude Opus 4.8 --- public/js/app.js | 2 +- public/js/format.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 59556ff..e99db2d 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1426,7 +1426,7 @@ function searchTable(rows) { ${rows.map((r, i) => ` ${f.esc(r.name)}${f.bytes(r.size)} ${r.seeds}${r.leeches} - ${f.esc(r.engine)}${f.ago(r.pubDate)} + ${f.esc(r.engine)}${r.pubDate ? f.esc(r.pubDate) : '–'} `).join('')} `; } diff --git a/public/js/format.js b/public/js/format.js index db2575c..8a8e061 100644 --- a/public/js/format.js +++ b/public/js/format.js @@ -44,15 +44,16 @@ export function ratio(r) { return r.toFixed(2); } -export function date(ms) { - if (!ms || ms < 0) return '–'; - const d = new Date(ms); +// Timestamps from the backend are Unix epoch SECONDS; 0/negative means "unset". +export function date(sec) { + if (!sec || sec < 0) return '–'; + const d = new Date(sec * 1000); return d.toLocaleString(undefined, { year: '2-digit', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); } -export function ago(ms) { - if (!ms || ms < 0) return '–'; - const s = (Date.now() - ms) / 1000; +export function ago(sec) { + if (!sec || sec < 0) return '–'; + const s = Date.now() / 1000 - sec; if (s < 60) return 'just now'; if (s < 3600) return `${Math.floor(s / 60)}m ago`; if (s < 86400) return `${Math.floor(s / 3600)}h ago`;