I'm pulling data from MySql and using it to create Zend_Measure objects. I'm
using the Zend_Measure component from the svn trunk.

I have a debian linux machine where the locale is set to en_US.UTF-8.

This line of code works fine on the machine noted above: $duration = new
Zend_Measure_Time($this->_attributes['duration'],
Zend_Measure_Time::STANDARD);

The same line of code on a mac with the locale set to fr_FR, the following
exception is thrown:

Uncaught exception 'Zend_Measure_Exception' with message 'No localized value
in 1095 found, or the given number does not match the localized format' in
/home/jasondeb/library/Zend/Measure/Abstract.php:203 Stack trace: #0
/home/jasondeb/library/Zend/Measure/Abstract.php(99):
Zend_Measure_Abstract->setValue('1095', 'SECOND', 'fr')

If I cast the value to an integer, no exception is thrown on the fr_FR
machine. And on the en_US machine it doesn't matter:

$duration = new Zend_Measure_Time((int) $this->_attributes['duration'],
Zend_Measure_Time::STANDARD); // Cast to integer NO PROBLEMS

If I explicitly set the locale to en_US and DO NOT cast the value to an int,
NO exception is thrown:

$locale = new Zend_Locale("en_US");
$duration = new Zend_Measure_Time($this->_attributes['duration'],
Zend_Measure_Time::STANDARD, $locale); // No cast to integer, but force
en_US locale NO PROBLEM on either machine

If I explicitly set the locale to fr_FR and DO NOT cast the value to an int,
the above exception IS thrown on both machines:

$locale = new Zend_Locale("fr_FR");
$duration = new Zend_Measure_Time($this->_attributes['duration'],
Zend_Measure_Time::STANDARD, $locale); // No cast to integer, set fr_FR
locale, Exception IS thrown

Is this expected behavior? Is there anything I am overlooing or just not
aware of? If this is expected behavior, could someone explain what effect
casting to an integer has on the fr_FR locale? I also wonder if other
locales than fr_FR would have the same problem.

If I had not used the fr_Fr locale machine this would have been a very
difficult error to find.

Thanks a lot.

Reply via email to