fix(bookmarks): show sane dates using created_at fallback to listUpdatedAt; guard formatters

This commit is contained in:
Gigi
2025-10-22 12:54:26 +02:00
parent c17eab5a47
commit 538cbd2296
4 changed files with 8 additions and 6 deletions

View File

@@ -5,13 +5,15 @@ import ResolvedMention from '../components/ResolvedMention'
// Note: RichContent is imported by components directly to keep this file component-only for fast refresh
export const formatDate = (timestamp: number) => {
const date = new Date(timestamp * 1000)
const safe = typeof timestamp === 'number' && isFinite(timestamp) && timestamp > 0 ? timestamp : Math.floor(Date.now() / 1000)
const date = new Date(safe * 1000)
return formatDistanceToNow(date, { addSuffix: true })
}
// Ultra-compact date format for tight spaces (e.g., compact view)
export const formatDateCompact = (timestamp: number) => {
const date = new Date(timestamp * 1000)
const safe = typeof timestamp === 'number' && isFinite(timestamp) && timestamp > 0 ? timestamp : Math.floor(Date.now() / 1000)
const date = new Date(safe * 1000)
const now = new Date()
const seconds = differenceInSeconds(now, date)