Globalize bug in new v1.2.1? Parsing certain numbers returns NaN for 17 cultures (India, Bangladesh, Bhutan)

137 views Asked by At

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):

var g = new Globalize("en-IN");
g.numberParser()(g.numberFormatter()(1000.01)); // prints 1000.01
g.numberParser()(g.numberFormatter()(999.99)); // prints NaN

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:

var g = new Globalize("en-IN");
console.log(g.numberParser()("1,000.01")) // prints 1000.01
console.log(g.numberParser()("100.01")) // prints NaN

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.

1

There are 1 answers

0
Rafael Xavier On BEST ANSWER

Update: This is fixed in Globalize 1.2.2.


Thanks for the great description. This is definitely a bug, I've filed it as https://github.com/globalizejs/globalize/issues/660.