feat: label stale evidence data
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user