ZF-6532: Zend_Filter_LocalizedToNormalized return date array instead of integer

Description

$filter = new Zend_Filter_LocalizedToNormalized(array('locale' => 'de','precision' => 0)); $val = $filter->filter( '1.000.000,00' );

$val should be 1000000 now, but is an array with date informations:

array ( [date_format] => dd.MM.yyyy, [locale] => de, [day] => 1, [month] => 000, [year] => 000 )

i posted that issue on zfforum.de: http://zfforum.de/showthread.php/?p=33370…

One answer is that it is possible that the 1.000.000,00 matches ISO-Dateformat on

line 101: Zend_Locale_Format::checkDateFormat($value, $this->_options)

Comments

I've met similar problem while playing with locales and this filter.


$locale = new Zend_Locale(Zend_Locale::ZFDEFAULT);
Zend_Registry::set('Zend_Locale', $locale);
###
$form = new Zend_Form;
$form->addElement('text', 'amount');
$form->amount->addFilter('LocalizedToNormalized');

When value "1,2.4" is passed to input amount, following error occours: preg_match() expects parameter 2 to be string, array given [trunk/lib/Zend/Locale/Format.php:515]

We have the same problem here - with an integer '10000'. Result is:

array ( [date_format] => dd.MM.yyyy, [locale] => de_DE, [day] => 10, [month] => 00, [year] => 0 )

This makes Zend_Filter_LocalizedToNormalized absolutely unusable for us.

Fixed with r15980.

Note that the value 1,2.4 is no number and will be detected as date.

Reason: Inputs like 01.02.04 -> 1. february 2004 or shortened also 1.2.4