webui: fix relative timestamps (seconds, not milliseconds)
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 <noreply@anthropic.com>
This commit is contained in:
parent
2df3f11cf4
commit
d1b90cfdcb
2 changed files with 8 additions and 7 deletions
|
|
@ -1426,7 +1426,7 @@ function searchTable(rows) {
|
|||
${rows.map((r, i) => `<tr>
|
||||
<td>${f.esc(r.name)}</td><td class="num">${f.bytes(r.size)}</td>
|
||||
<td class="num" style="color:var(--up)">${r.seeds}</td><td class="num dim">${r.leeches}</td>
|
||||
<td class="dim">${f.esc(r.engine)}</td><td class="num dim">${f.ago(r.pubDate)}</td>
|
||||
<td class="dim">${f.esc(r.engine)}</td><td class="num dim">${r.pubDate ? f.esc(r.pubDate) : '–'}</td>
|
||||
<td><button class="btn" data-sr="${i}">+ Add</button></td></tr>`).join('')}
|
||||
</tbody></table>`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue