Categories > TinyButStrong general >

Bug in numeric formatting: prefix/postfix with padding

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sheepy
Date: 2013-09-06
Time: 10:43

Bug in numeric formatting: prefix/postfix with padding

Found a bug in numeric formatting.
       
Specifically, string prefix and postfix are not compatible with number padding.

include( 'tbs_class.php' );
$TBS = new clsTinyButStrong();
$TBS->Source = '[fld;frm=$0000000.]';
$TBS->MergeField( 'fld', 2456.1426 );
$TBS->Show();

// Expected: $0002456
// Result: 00$2456

Fix:

In my 3.8.3-beta, padding is applyed after prefix/postfix processing, at line 3119.
Reversing the order, so that str_pad goes right before str_replace, seems to fix the issue.
By: Sheepy
Date: 2013-09-06
Time: 10:47

Re: Bug in numeric formatting: prefix/postfix with padding

By the way, the third numeric example for numeric formatting seems to be wrong.

It says:

[fld;frm='$ 0,000.']     2,456

But as I test it, the actual result is $ 2,456.
By: Skrol29
Date: 2013-09-07
Time: 01:55

Re: Bug in numeric formatting: prefix/postfix with padding

Hi Sheepy,

Thanks for this information.

> But as I test it, the actual result is $ 2,456.

Fixed in the manual.

>In my 3.8.3-beta, padding is applyed after prefix/postfix processing, at line 3119.
>Reversing the order, so that str_pad goes right before str_replace, seems to fix the issue.

Fixed in the beta.
And I've complete the unit tests in order to check this case.

You can download the new version here:
http://www.tinybutstrong.com/dl.php?f=tbs_beta.zip&s=2