29 lines
642 B
TypeScript
29 lines
642 B
TypeScript
import {AtUri} from '@atproto/api'
|
|
|
|
export function niceDate(date: number | string | Date) {
|
|
const d = new Date(date)
|
|
return `${d.toLocaleDateString('en-us', {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
})} at ${d.toLocaleTimeString(undefined, {
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
})}`
|
|
}
|
|
|
|
export function getRkey({uri}: {uri: string}): string {
|
|
const at = new AtUri(uri)
|
|
return at.rkey
|
|
}
|
|
|
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
notation: 'compact',
|
|
maximumFractionDigits: 1,
|
|
roundingMode: 'trunc',
|
|
})
|
|
|
|
export function prettyNumber(number: number) {
|
|
return formatter.format(number)
|
|
}
|