Files
vps-tracker/apps/web/src/lib/sync-format.ts
T
DenozordecandCursor 1e291b3759
Docker / build (push) Has been cancelled
feat(web): доработка UX/UI — дашборд, навигация и data foundation
Добавлены syncLog в snapshot, API статистики дашборда и маппинг цен тарифов; переработаны shell, главная страница, empty states и новые экраны журнала синка и проектов.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 00:27:09 +07:00

14 lines
545 B
TypeScript

export function formatRelativeSyncTime(iso: string | null | undefined): string {
if (!iso) return 'нет данных'
const t = new Date(iso).getTime()
if (Number.isNaN(t)) return 'нет данных'
const diffMs = Date.now() - t
const mins = Math.floor(diffMs / 60_000)
if (mins < 1) return 'только что'
if (mins < 60) return `${mins} мин назад`
const hours = Math.floor(mins / 60)
if (hours < 48) return `${hours} ч назад`
const days = Math.floor(hours / 24)
return `${days} дн назад`
}