This commit is contained in:
nate 2026-04-09 18:04:42 +04:00
parent 17fe00d123
commit f9801345ae
2 changed files with 2 additions and 2 deletions

View File

@ -26,7 +26,7 @@ async function api(path, opts = {}) {
} }
function formatAgo(ms) { function formatAgo(ms) {
const s = Math.max(0, Math.ceil(ms / 1000)); const s = Math.max(0, Math.floor(ms / 1000));
if (s < 60) return `${s}s ago`; if (s < 60) return `${s}s ago`;
if (s < 3600) return `${Math.floor(s / 60)}m ago`; if (s < 3600) return `${Math.floor(s / 60)}m ago`;
if (s < 86400)return `${Math.floor(s / 3600)}h ago`; if (s < 86400)return `${Math.floor(s / 3600)}h ago`;

View File

@ -18,7 +18,7 @@ const eta = new Eta({ views: resolve(import.meta.dir, "../views"), cache: true,
function timeAgoSSR(date: string | Date): string { function timeAgoSSR(date: string | Date): string {
const ts = new Date(date).getTime(); const ts = new Date(date).getTime();
const s = Math.max(0, Math.ceil((Date.now() - ts) / 1000)); const s = Math.max(0, Math.floor((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`; 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 `<span class="timestamp" data-ts="${ts}">${text}</span>`; return `<span class="timestamp" data-ts="${ts}">${text}</span>`;
} }