[Glass] Locale decimalPoint into html rendering

Dario Trussardi via Glass glass at lists.gemtalksystems.com
Thu Mar 19 03:48:00 PDT 2015


Ciao,

	i have a tODE 3.1.0.6  environment.

	On it i set the TimeZone with:

| time |
time:= TimeZone timeDifferenceHrs: 1 dstHrs: 1 atTimeHrs: 2
fromDayNum: 95 toDayNum: 304 on:  #Sunday beginning: 1967
stdPrintString: 'Germany Standard Time' dstPrintString: 'Germany Legal Time'.
TimeZone for:#Germany put: time.
TimeZone default: time

	Now the		 Locale decimalPoint 		is set to $,   ( comma )	 and it's right.


The :	( ScaledDecimal fromString: '12,34'   ) asString 		report 	'12,34'		and it's right with comma.


The problem is into relative   html web rendering.

In this case the browser  report  the data,	 not with comma,		 but with decimal point	12.34   and it's wrong.

The relative ScaledDecimal  method

	asString

"Returns a String of the form '123.56 for a number with scale = 2."

| str mstr sc sz len isNeg m dpStr nDigits |
(m := mantissa) ifNil:[ ^ 'ScaledDecimalNaN' ].
mstr := m asString .
len := mstr size .
sz := len .
sc := scale.
nDigits := sz .
(isNeg := (mstr at: 1) == $-) ifTrue:[ nDigits := nDigits - 1 ].
dpStr :=  Locale decimalPoint.
str := String new .
nDigits <= sc  ifTrue:[ | prefix zeros zerosLen zcount idx srcIdx |
  isNeg ifTrue:[ str add: $- ] .
  str add: $0 ; add: dpStr .
  zeros := '00000000000000000000000000000000000000000000000000000000000000000' .
  zerosLen := zeros size .
  zcount := sc - nDigits .
  [ zcount >= zerosLen ] whileTrue:[
    str add: zeros .
    zcount := zcount - zerosLen .
  ].
  zcount > 0 ifTrue:[ 
    "zeros copyFrom: 1 to: zcount into: str startingAt: str size + 1"
    idx := str size .
    str replaceFrom: idx + 1 to: idx + zcount with: zeros startingAt: 1 .
  ].
  "mstr copyFrom: len - nDigits + 1 to: len into: str startingAt: str size + 1"
  idx := str size + 1 .
  srcIdx := len - nDigits + 1 .
  str replaceFrom: idx  to: idx + nDigits - 1  with: mstr startingAt: srcIdx 
 ] ifFalse:[  
  str := mstr .
 " add dpStr only if with decimals "
 sc>0 ifTrue:[ str insertAll: dpStr at: (sz + 1 - sc )] . 
].
^ str

do reference to the	 Locale decimalPoint 		but when work to rendering as html data it wrong.

I need to force into the upper method the :		dpStr :=  Locale decimalPoint.

	to:				dpStr:= $,

With this force the html data is right rendering  but it's a force.

Thanks for considerations,

	Dario

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20150319/407b6750/attachment.html>


More information about the Glass mailing list