Open maxkan opened 7 years ago
Hi @maxkan!
Hmm, adding this ability to the formatter would make it much more complicated. There are many currency symbols and the mask could also include a longer prefix (e.g. The amount was € #,##0.
)
Maybe adding a placeholder to the mask for the positive and/or negative sign would work better. Something like this:
format("$#,##0.", 100); // 0
format("$#,##0.", -100); // $-100
format("{-}$#,##0.", 100); // 0
format("{-}$#,##0.", -100); // -0
format("{+-}$#,##0.", 100); // +0
What do you think?
And I actually thought Excel wrapped negative numbers in parenthesis (e.g. (12.34) = -$12.34
). Did that change?
It's customizable in Excel. As a variant it can be done using separate methods like formatCurrency. But a lot of people is familiar with Excel custom cell format and as I see it the closer this lib to Excel formatting the more useful it is because you can just use the format you know and receive the result you expect.... As for now I'm checking if the value is negative and adding '-' manually.
format('$#,##0.', -100) should return '-$100', the same way as Excel does it