2021-12-11 03:47:46 +00:00
|
|
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
|
|
style: 'currency',
|
|
|
|
currency: 'USD',
|
|
|
|
maximumFractionDigits: 0,
|
2021-12-14 07:09:46 +00:00
|
|
|
minimumFractionDigits: 0,
|
2021-12-11 03:47:46 +00:00
|
|
|
})
|
|
|
|
|
2021-12-11 04:09:32 +00:00
|
|
|
export function formatMoney(amount: number) {
|
2021-12-24 21:06:01 +00:00
|
|
|
return 'M$ ' + formatter.format(amount).replace('$', '')
|
2021-12-11 03:47:46 +00:00
|
|
|
}
|
2021-12-11 04:09:32 +00:00
|
|
|
|
|
|
|
export function formatWithCommas(amount: number) {
|
2021-12-24 21:06:01 +00:00
|
|
|
return formatter.format(amount).replace('$', '')
|
2021-12-15 07:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function formatPercent(zeroToOne: number) {
|
|
|
|
return Math.round(zeroToOne * 100) + '%'
|
2021-12-11 04:09:32 +00:00
|
|
|
}
|