summaryrefslogtreecommitdiffstats
path: root/frontend/lib
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-03-14 12:19:54 -0400
committerWes Bos <wesbos@gmail.com>2018-03-14 12:19:54 -0400
commit331da87bd53bc1fb79063d142764c75df9f32170 (patch)
treed80aac98154a811fdf57b10e90ac0350fe14568e /frontend/lib
parent46a0ba30ef54a7e36206481a4f5b2bf1f9702fca (diff)
tests
Diffstat (limited to 'frontend/lib')
-rw-r--r--frontend/lib/formatMoney.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/frontend/lib/formatMoney.js b/frontend/lib/formatMoney.js
index edddf48..301f01f 100644
--- a/frontend/lib/formatMoney.js
+++ b/frontend/lib/formatMoney.js
@@ -1,3 +1,11 @@
-export default function(amount) {
- return '$' + (amount / 100).toLocaleString();
+export default function (amount) {
+ const options = {
+ style: 'currency',
+ currency: 'USD',
+ minimumFractionDigits: 2,
+ };
+ // if its a whole, dollar amount, leave off the .00
+ if (amount % 100 === 0) options.minimumFractionDigits = 0;
+ const formatter = new Intl.NumberFormat('en-US', options);
+ return formatter.format(amount / 100);
}