Issues

ZF-10358: Zend_Date improperly recognize year when date with custom format is created

Description

There is an issue while creating new Zend_Date with specific format being set, in this case Twitter-specific date format (in which is e.g. 'created_at' field of zend_service_twitter response).

The date in its pure form is eg. "Sat Aug 21 18:50:20 +0000 2010", which corresponds to the format "EEE MMM d H:m:s ZZZ yyy" in en_US locale.

Example: $date = new Zend_Date("Sat Aug 21 18:50:20 +0000 2010", 'EEE MMM d H:m:s ZZZ yyy', 'en_US'); echo $date->get(Zend_Date::ISO_8601);

Expected output: 2010-08-21T18:50:20+00:00

Current output: 2000-08-21T18:50:20+00:00 // the year is 2000 instead of 2010

Comments

Shouldn't it read $date = new Zend_Date("Sat Aug 21 18:50:20 +0000 2010", "EEE MMM d H:m:s ZZZ yyyy", 'en_US');?

In fact, in this case is the output weird as well:

{{0-08-21T18:50:20+00:00}}

Looks like the year is not recognized at all...

same happens in ZF 1.11.5

This is my workaround:


$date = new Zend_Date( strtotime($tweet['created_at']) );

Still happens in 1.11.10.

The problem seems to be in Zend_Locale_Format : the _parseDate() method ignore the ZZZZ format, but consider the date part 0000 as the year instead of 2010.

I add a patch that solves the problem for me.