Something went wrong. Try again.
A self-hosted household ledger.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637const formatters = new Map<string, Intl.NumberFormat>();
export function formatCents(cents: number, currency = "USD"): string { let fmt = formatters.get(currency); if (!fmt) { fmt = new Intl.NumberFormat(undefined, { style: "currency", currency }); formatters.set(currency, fmt); } return fmt.format(cents / 100);}
const dateFmt = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric",});const dateFmtFull = new Intl.DateTimeFormat(undefined, { year: "numeric", month: "short", day: "numeric",});
export function formatDay(unixSeconds: number): string { const date = new Date(unixSeconds * 1000); const now = new Date(); return date.getFullYear() === now.getFullYear() ? dateFmt.format(date) : dateFmtFull.format(date);}
export function formatMonth(month: string): string { const [y, m] = month.split("-").map(Number); return new Intl.DateTimeFormat(undefined, { month: "long", year: "numeric" }) .format( new Date(Date.UTC(y, m - 1, 15)), );}