Something went wrong. Try again.
Beautiful changelogs and releases for everything
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859// TID rkeys carry creation time: 13 chars of base32-sortable// alphabet, top 53 bits are microseconds since the Unix epoch.const S32 = '234567abcdefghijklmnopqrstuvwxyz'
export function tidToDate(tid: string): Date | null { if (tid.length !== 13) return null let value = 0n for (const c of tid) { const i = S32.indexOf(c) if (i < 0) return null value = value * 32n + BigInt(i) } const micros = value >> 10n return new Date(Number(micros / 1000n))}
export function formatDate(d: Date | null): string { if (!d) return '' return d.toLocaleDateString('en-CA', { year: 'numeric', month: 'short', day: 'numeric' })}
// Fresh ink reads as recency, not a date; past two weeks the// ledger settles into absolute dates.export function freshness(d: Date | null): string | null { if (!d) return null const days = Math.floor((Date.now() - d.getTime()) / 86_400_000) if (days < 0 || days > 13) return null if (days === 0) return 'today' if (days === 1) return 'yesterday' return `${days} days ago`}
// Visual clamps cap lines; the string itself stays short so// assistive tech hears an excerpt, not the whole changelog.export function excerpt(text: string, max = 280): string { if (text.length <= max) return text const cut = text.slice(0, max) const sp = cut.lastIndexOf(' ') return (sp > 0 ? cut.slice(0, sp) : cut) + '…'}
export function formatBytes(n: number): string { if (n < 1024) return `${n} B` const units = ['KB', 'MB', 'GB', 'TB'] let v = n let u = -1 do { v /= 1024 u++ } while (v >= 1024 && u < units.length - 1) return `${v >= 10 ? Math.round(v) : v.toFixed(1)} ${units[u]}`}
export function truncateDigest(digest: string): string { const [algo, hex] = digest.split(':') if (!hex) return digest return `${algo}:${hex.slice(0, 12)}…`}