formatMoney: handle minus zero

This commit is contained in:
mantikoros 2022-03-09 23:17:26 -06:00
parent b81742cd02
commit b550bbe07d

View File

@ -6,7 +6,8 @@ const formatter = new Intl.NumberFormat('en-US', {
}) })
export function formatMoney(amount: number) { export function formatMoney(amount: number) {
return 'M$ ' + formatter.format(amount).replace('$', '') const newAmount = Math.round(amount) === 0 ? 0 : amount // handle -0 case
return 'M$ ' + formatter.format(newAmount).replace('$', '')
} }
export function formatWithCommas(amount: number) { export function formatWithCommas(amount: number) {