feat: label stale evidence data

This commit is contained in:
ik
2026-09-20 20:21:39 +07:00
parent 1dfe1e8ba4
commit 5a8174b11e
6 changed files with 25 additions and 9 deletions
+7
View File
@@ -20,3 +20,10 @@ export function ago(value: string) {
const minutes = Math.max(0, Math.round((Date.now() - new Date(value).getTime()) / 60000));
return minutes < 60 ? `${minutes} мин назад` : `${Math.floor(minutes / 60)} ч назад`;
}
export function freshnessStatus(value: string | null | undefined, now = Date.now()): "fresh" | "stale" | "unknown" {
if (!value) return "unknown";
const timestamp = new Date(value).getTime();
if (!Number.isFinite(timestamp)) return "unknown";
return now - timestamp > 48 * 60 * 60 * 1000 ? "stale" : "fresh";
}