mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {AtUri} from '@atproto/api'
2
3export function niceDate(date: number | string | Date) {
4 const d = new Date(date)
5 return `${d.toLocaleDateString('en-us', {
6 year: 'numeric',
7 month: 'short',
8 day: 'numeric',
9 })} at ${d.toLocaleTimeString(undefined, {
10 hour: 'numeric',
11 minute: '2-digit',
12 })}`
13}
14
15export function getRkey({uri}: {uri: string}): string {
16 const at = new AtUri(uri)
17 return at.rkey
18}
19
20const formatter = new Intl.NumberFormat('en-US', {
21 notation: 'compact',
22 maximumFractionDigits: 1,
23 roundingMode: 'trunc',
24})
25
26export function prettyNumber(number: number) {
27 return formatter.format(number)
28}