Zend Framework

Zend_Filter_LocalizedToNormalized return date array instead of integer

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.0
  • Fix Version/s: 1.9.0
  • Component/s: Zend_Filter
  • Labels:
    None

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://www.zfforum.de/showthread.php?p=33370#post33370

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)

Activity

Hide
Piotr Czachur added a comment -

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]

Show
Piotr Czachur added a comment - 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]
Hide
Stephan Wentz added a comment -

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.

Show
Stephan Wentz added a comment - 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.
Hide
Thomas Weidner added a comment -

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

Show
Thomas Weidner added a comment - 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

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: