Zend Framework

Zend_Locale_Format::checkDateFormat() incorrect handles dates with zero parts

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.10.6
  • Fix Version/s: 1.10.7
  • Component/s: Zend_Locale
  • Labels:
    None

Description

Zend_Locale_Format::checkDateFormat() incorrect handles dates with zero parts.

Steps to reproduce

$filter = new Zend_Filter_LocalizedToNormalized(array('date_format' => 'M/d/yy h:mm a'));
var_dump($filter->filter('06/23/10 12:00 AM'));

returns:

string(17) "06/23/10 12:00 AM"

but should return array:

array(7) {
  ["date_format"]=>
  string(13) "M/d/yy h:mm a"
  ["locale"]=>
  string(2) "en"
  ["month"]=>
  string(2) "06"
  ["day"]=>
  string(2) "23"
  ["year"]=>
  int(2010)
  ["hour"]=>
  int(0)
  ["minute"]=>
  string(2) "00"
}

Cause of Issue

Zend_Locale_Format on line 1160 has such comparison: {{$date['hour'] == "",}} but (int)0 == (string)"".

Suggested solution

Cast to string before comparison.

Activity

Hide
Vadim Kusakin added a comment -

It's patch for trunk.

Show
Vadim Kusakin added a comment - It's patch for trunk.
Hide
Thomas Weidner added a comment -

Patch not accepted.
It breaks functionality and fails several unittests.

Show
Thomas Weidner added a comment - Patch not accepted. It breaks functionality and fails several unittests.
Hide
Thomas Weidner added a comment -

Fixed with r22552

Show
Thomas Weidner added a comment - Fixed with r22552

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: