🎉 init
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user