Closed rxaviers closed 7 years ago
The bug seems related to parsing a number that has 2nd grouping separator. parsing 1,000
works, but 1000
doesn't.
Due to the same root cause, Globalize('en').parseNumber('1', {style: 'percent'})
was wrongly returning 1
instead of NaN
.
Reported via http://stackoverflow.com/questions/41221215/globalize-bug-in-new-v1-2-1-parsing-certain-numbers-returns-nan-for-17-cultures
With the new version 1.2.1 of Globalize we're seeing 17 cultures for which parsing fails for numbers in the "hundreds" range (e.g. between 100 and 999).
Here's a concrete example using the CLDR JSON data version 30.0.2 (also tested with the CLDR 30.0.3 data with the same results):
To the best of my knowledge, formatting the number 999.99 and then parsing it should not yield
NaN
, so this looks like a bug.NaN
is also the result for the number 100, and indeed it seems like it's the result for any number with three significant digits.If we just focus on the parsing step, we see the following:
If we use the earlier Globalize code from version 1.1.2 then the behavior is correct (i.e. no NaN problems).
The 17 cultures in question are:
as-IN,bn-BD,bn-IN,brx-IN,dz-BT,en-IN,gu-IN,hi-IN,kok-IN,ks-Arab-IN,ml-IN,mr-IN,or-IN,pa-IN,ta-IN,ta-LK,te-IN
. Our unit tests picked them all up after we upgraded to Globalize 1.2.1.We're wondering if somebody might be kind enough confirm that they can reproduce this (is there a jsfiddle template for doing this sort of thing?), and which change in the new version of Globalize (assuming it is a problem in Globalize) is causing this so that we can perhaps post a corresponding issue.