Numeral-js icon indicating copy to clipboard operation
Numeral-js copied to clipboard

Support for Indian and other similar number formats

Open apapirovski opened this issue 12 years ago • 10 comments

Was just talking to a friend about this and in parts of India (or maybe everywhere in India) they format numbers like so: 1,00,00,000 (separator after hundreds until the last thousand) which right now, I believe, is impossible to re-create. There are probably other languages too that format their numbers like this or even more differently.

This is probably a substantial change to how Numeral-js does things. To solve, I assume Numeral-js would need to allow functions instead of objects for the "separator" property of a language which would then allow people to write their own custom formatters. The other possibility is allowing them to specify a custom format like so: '00,00,00,00,00,00,000.00' or something, but that seems kind of unwieldy since you have to make it arbitrarily big to make sure it always works.

apapirovski avatar Nov 02 '12 17:11 apapirovski

is you look at the MS C# and Ajax formatting rules, they specify a seperator and then a group size e.g. [2, 3] and you count from the right and if you hit the end of the definition, you repeat. This could easily be added on as an additional option which would default to [3].

lukeapage avatar Nov 20 '13 08:11 lukeapage

http://en.wikipedia.org/wiki/Decimal_mark#Digit_grouping

It looks like China and Japan group them as in 1,0000,0000,0000.

The Indian number system looks like it's the most complex. It appears as though everyone else uses either 3 or 4 digit groupings.

jokeyrhyme avatar Feb 11 '14 06:02 jokeyrhyme

Yes, I need Indian currency formatting and will need to roll my own solution...

MSCAU avatar Jul 03 '16 04:07 MSCAU

Any progress on this? Thanks

TimBailey-pnk avatar Jun 29 '17 04:06 TimBailey-pnk

+1 this. Everyone in India uses that format

ooooak avatar Dec 01 '17 08:12 ooooak

The number format specified above incorrect, and is not as simple. The actual format used is a repeating pattern of groups of 3;2;2. I.e., to write hundred trillion (100,000,000,000,000 or 10E14), you would write as 1,00,00,000,00,00,000. It would be read as one crore crore. One crore basically is 10 million and has seven zeros which are grouped together.

sivarajd avatar Mar 16 '18 08:03 sivarajd

any progress on this ? as kibana use numeral-js , and i have requirement where i want show data abbreviation as 1 crore instead of 10 million

DilipVxceed avatar Jul 09 '20 19:07 DilipVxceed

@DilipVxceed I ended up creating my own package called inrformat.

npm: https://www.npmjs.com/package/inrformat source: https://github.com/ooooak/inrformat

ooooak avatar Jul 10 '20 10:07 ooooak

@ooooak can you tell me how can i use your package in kibana..

Itsmeak0910 avatar Aug 19 '21 15:08 Itsmeak0910

Hi,

I just forked the repo and made few changes in it and published my own package. Now it supports India currency.

Checkout - https://www.npmjs.com/package/numeral-v2

Doc - https://numeraljs.netlify.app/

Thanks, Pratik Patel

pratik227 avatar Feb 10 '23 13:02 pratik227