Files
splitt-the-bill/shared/utils/money.ts
T
2026-07-01 15:43:18 +02:00

12 lines
338 B
TypeScript

export function toCents(amount: number): number {
return Math.round(amount * 100)
}
export function fromCents(cents: number): number {
return cents / 100
}
export function formatCurrency(cents: number, currency: string): string {
return new Intl.NumberFormat(undefined, { style: 'currency', currency }).format(fromCents(cents))
}