Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#10701 closed defect (fixed)

type:percent parsing problem in number.parse

Reported by: doughays Owned by: peller
Priority: high Milestone: 1.5
Component: Core Version: 1.4.0
Keywords: Cc:
Blocked by: Blocking:


I'm trying to add type:percent support to NumberTextBox but I can't get some simple examples to work.

dojo.number.parse("12%", {places:0, locale: "en-us", type: "percent"}) 
  returns 0.12 so that seems right except places:0 must only apply to the input format and not the output.
dojo.number.parse("12.3%", {places:0, locale: "en-us", type: "percent"}) 
  returns NaN so I guess that's because of places:0.
dojo.number.parse("12.3%", {places:1, locale: "en-us", type: "percent"}) 
  returns NaN and I don't understand why.

It looks like percent only works with places:0 .
Getting this to work is a prereq for #10582.

Change History (5)

comment:1 Changed 8 years ago by peller

  • Milestone changed from tbd to 1.5
  • Status changed from new to assigned

comment:2 Changed 7 years ago by peller

Apparently this stems from the fact that percentFormat in the CLDR is given as "#,##0%" which the code interprets as accepting only whole numbers, regardless of the decimal setting. "#,##0.###%" would seem more consistent with numberFormat. We may need to provide a special case in the code here.

comment:3 Changed 7 years ago by peller

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [21792]) Allow decimal places when parsing numbers type=percent. Fixes #10701, Refs #10582

comment:4 Changed 7 years ago by peller

(In [21951]) Redo r21792 to avoid exception when parts[1] is null and options.places is unspecified. Refs #10701, Refs #10582

comment:5 Changed 7 years ago by peller

(In [21971]) Strip out location-dependent timezone from date format test. Refs #10692 Add number percent test. Refs #10701, #10582

Note: See TracTickets for help on using tickets.