Comments (5)
Fair point - I'm from the UK as well, which is IMHO the only place in the world that does currency right.. I agree that a user shouldn't have to see EU-style formatting if they're used to standard formatting, or vice-versa..
Having said that, I think this is something that will be best handled by the parameters passed to the method (and in the next version, some form of configuration/settings object) - which leaves it squarely up to the developer. I'd say the job of the library is to provide a way of making that as easy as possible for them to present the correct number formatting for any given user.
It would definitely be an application-specific method of defining which locale to set, so I think this will be solved by the planned global settings configuration for the next version. Hope you can check it out when it's updated and let me know your thoughts!
Oh and thanks for the link, I'll take a look over it.
from accounting.js.
Currency is just a unit, just like weight, pressure, temperature, distance or density. The value (number) is seperate from that.
I agree about the parameter, a quick google suggests there is little you can garner from the client itself. Perhaps a global configuration overridable by a parameter would be the best approach.
from accounting.js.
Yeah, good call. Working on that now.
from accounting.js.
Damn comment & close button :)
from accounting.js.
Hey, I've just pushed v0.1.3 which adds a configurable settings
object, which allows a developer to set the global localisation defaults under two objects, currency
and number
:
// Settings object that controls default parameters for library methods:
accounting.settings = {
currency: {
symbol : "$", // default currency symbol is '$'
format: "%s%v", // this controls string output: %s = symbol, %v = value/number
decimal : ".", // decimal point separator
thousand: ",", // thousands separator
precision : 2 // decimal places
},
number: {
precision : 0, // default precision on numbers is 0
thousand: ",",
decimal : "."
}
}
I'm leaving it up to individual developers and applications to decide which formatting to show the user, but I do have plans to build an optional plugin with default locale data for some common regions or countries... more on that later.
Until then I'd say this one's wrapped up, though there's more to do fo' sho'
Please re-open or make a new issue if you find bugs in the new code. Cheers!
from accounting.js.
Related Issues (20)
- G3O
- formatMoney(17604.045)is wrong , HOT 3
- Wrong rounding on toFixed() for negative numbers
- formatMoney preserve original precision
- How to always get value up
- Optional format values are not optional
- parse currency unit in unformat?
- Rounding issue [574.425 should be rounded to 574.43] HOT 2
- issues100
- T
- Rt
- toFixed does not play well with long decimal values.
- Role of Chartered Accounting Firms towards achieving economic development
- Error reading package.json HOT 1
- formatMoney(17604.045)is wrong ,
- G3O
- Outlook HOT 1
- Is this lib dead? HOT 1
- `unformat()` returns the wrong value if currency symbol contains the decimal separator
- Tiny numbers lead to `NaN.undefined`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from accounting.js.