question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format dollars only when cents are 0

See original GitHub issue

Suppose I have precision=2 in dollars. However when the value is whole dollars, it is overwhelming for the user to see $50.00, instead of just $50. I propose adding yet another config option to indicate whether currency.js should do such formatting. For example: { omitZeroCents: true }.

If this proposal sounds well, I am willing to make a PR. Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
scurkercommented, Jul 12, 2020

v2.0.0 has just been released where the formatter can now be a function allowing you to customize the output formatting (see https://github.com/scurker/currency.js/issues/191#issuecomment-529201820) for example

0reactions
Dragomir-Ivanovcommented, Jul 12, 2020

Thanks a lot! Will look it up, and probably migrate. Kudos for the good work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Format numbers as currency - Microsoft Support
In the Symbol box, click the currency symbol that you want. Note: If you want to display a monetary value without a currency...
Read more >
c# - String.Format way to format Currency without Cents
We will be dealing with large dollar amounts, and no cents. We would like the currency to display as $10 without the decimal...
Read more >
How to Format Money in General Writing
Just as everyone handles money differently, you can format money differently depending on ... Spell out references to dollars and cents without numerals.1....
Read more >
How To Write Dollars and Cents on a Check - The Balance
You might have noticed that the last example was for less than one dollar. To write a check for less than a full...
Read more >
Is there a custom format in excel to show cents values without ...
How about multiplying your value by 100, then using your format with a space in place of the decimal point. Of course, you'd...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found