/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
apps/dashboard/src/utils/format-date.ts
24 строки
561 B
cursor[bot]
chore(root): remove 5 unused exports from dashboard (#10592)
08 апр 2026, 16:02
Не верифицирован
08 апр 2026, 16:02
8ea2aa5
Код
Авторство
О чём код?
import { formatDistance, isAfter, subDays } from 'date-fns'; export function formatDateSimple( date: string, options: Intl.DateTimeFormatOptions = { year: 'numeric', month: 'short', day: 'numeric', } ) { const dateObj = new Date(date); const oneDayAgo = subDays(new Date(), 1); if (isAfter(dateObj, oneDayAgo)) { const timeAgo = formatDistance(dateObj, new Date(), { addSuffix: true, includeSeconds: true, }); return timeAgo.replace('about ', ''); } return dateObj.toLocaleDateString('en-US', options); }