Opened 8 years ago

Closed 4 years ago

#14420 closed defect (patchwelcome)

dojo.number.parse() doesn't recognize numbers in "012,677.00" pattern

Reported by: Evan Owned by: Adam Peller
Priority: low Milestone: 1.13
Component: Core Version: 1.6.1
Keywords: number, parse, pattern Cc: jianqin@…
Blocked By: Blocking:

Description

Not sure if this an expected result or a defect, following usage will get a NaN

// ---> NaN
dojo.number.parse("01,23.00", {pattern : '00,00.00', locale : 'en'});

While the result is correct for

// ---> 123
dojo.number.parse("1,23.00", {pattern : '00,00.00', locale : 'en'});

Please try the test case to see the observations.

Attachments (1)

14420 .html (610 bytes) - added by Evan 8 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 8 years ago by Evan

Cc: jianqin@… added

Changed 8 years ago by Evan

Attachment: 14420 .html added

comment:2 Changed 8 years ago by Evan

Priority: normalhigh

comment:3 Changed 8 years ago by Adam Peller

I think the second example should actually fail because 0 implies a mandatory digit, so both tests are failing

comment:4 Changed 8 years ago by Adam Peller

The Java number format syntax is a little odd. The common usage is 0 for required decimal places, and a single 0 to the left of the decimal point, with #'s everywhere else to represent optional digits. Usually you'd only put enough digits to show the first separator (i.e. thousands: #,##0) Anything beyond that is probably not used unless there's a second thousands separator -- to support the Indian number format which uses a mixture of two different groupings, something like #,##,###.0

The error you show above only seems to happen when the leading number is a '0', so I think that might be the bug you're after. Other inputs seem to work fine. We don't have a test case with a leading zero and a thousands separator.

comment:5 Changed 8 years ago by bill

Milestone: tbd

comment:6 Changed 8 years ago by Colin Snover

Priority: highblocker

Bulk update of open ticket priorities.

comment:7 Changed 7 years ago by Adam Peller

Priority: blockerlow

comment:8 Changed 4 years ago by dylan

Milestone: tbd1.12
Resolution: patchwelcome
Status: newclosed

Given that no one has shown interest in creating a patch in the past 4+ years, I'm closing this as patchwelcome.

Note: See TracTickets for help on using tickets.