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`;