Issues

ZF-12181: Format of a negative number with precision 0 is ignored using locale of en_PY

Issue Type: Bug Created: 2012-04-28T21:32:55.000+0000 Last Updated: 2012-10-03T08:34:13.000+0000 Status: Open Fix version(s): Reporter: Leslie Harrison (lesliehh) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

  • Zend_Locale_Format

Related issues: Attachments:

Description

Using locale of es_PY and Zend_Currency, was trying to get a negative currency value using precision of 0. The positive values comes out good, the problem is when the value is a negative number. The negative currency ignores precision settings.

<pre class="highlight"> 
$locale = new Zend_Locale('es_PY');
$currency = new Zend_Currency(array('precision' => '0'), $locale);



<pre class="highlight"> 
// With value of -50000, it should show ₲ -50.000
$this->currency(-50000) // ₲ -50.000.00 
// With value of 50000, it has no problem
$this->currency(50000) // ₲ 50.000

I was able to do a quick fix and get the result I wanted by commenting out a line in Zend_Locale_Format. It is not a fix, as I do not know whether the change I made breaks anything else. I am not a "pro" in programming, just 3-4 years of experience with it. Thought I'd report this as it was bugging me for a while.

This is the original code from Zend_Locale_Format starting on line 417:

<pre class="highlight"> 
        if ($options['precision'] == '0') {
            if (iconv_strrpos($format, '-') != 0) {
                $format = iconv_substr($format, 0, $point);
                        . iconv_substr($format, iconv_strrpos($format, '#') + 2);
            } else {
                $format = iconv_substr($format, 0, $point);
            }
        } else {
            $format = iconv_substr($format, 0, $point) . $symbols['decimal']
                               . iconv_substr($prec, 2);
        }

The change I made was to comment out the concatenation on line 420.

<pre class="highlight"> 
        if ($options['precision'] == '0') {
            if (iconv_strrpos($format, '-') != 0) {
                $format = iconv_substr($format, 0, $point);
                        // TODO: Make the quickfix a proper fix.
                        // The below portion was concatonated with the statement above
                        //. iconv_substr($format, iconv_strrpos($format, '#') + 2);
            } else {
                $format = iconv_substr($format, 0, $point);
            }
        } else {
            $format = iconv_substr($format, 0, $point) . $symbols['decimal']
                               . iconv_substr($prec, 2);
        }

Comments

Posted by Benno (benno) on 2012-10-03T08:34:13.000+0000

Same problem here, using «es_CL» as locale.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts