[Glass] Locale decimalPoint into html rendering

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Glass] Locale decimalPoint into html rendering

GLASS mailing list
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


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Locale decimalPoint into html rendering

GLASS mailing list
Thanks Dario,

I've submitted a bug[1] for this...

[1] https://github.com/GsDevKit/GsDevKit/issues/59

On 3/19/15 3:48 AM, Dario Trussardi via Glass wrote:
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



_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass