Issues

ZF-9711: Bug (?) with dates of February month for leap years earlier than 1900

Description

Hi,

it seems to me there is a bug in Zend_date related to leap years earlier than 1900. The problem occurs only with February days.

I construct a date: $myDate = new Zend_Date('25/02/1824', 'dd/MM/YYYY');

Then I display it using a different format:

echo $myDate->toString('YYYY/MM/dd');

The result is: 1824/02/26

The day is changed !?!?

I made several tests, and it seems to me that this problem occurs only with dates of February month in leap years before 1900.

Are dates earlier than 1900 are supposed to be supported by Zend_Date ? Did I miss something (explicitly configuring something, like timezone ... ?)

UPDATE: I posted a test file to reproduce the problem. The code is:

<?php defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(FILE) . '/'));

set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/library'), get_include_path())));

require_once 'Zend/Date.php';

$strInitialDate='25/02/1824'; $myDate = new Zend_Date($strInitialDate, 'dd/MM/YYYY'); $strFormattedDate= $myDate->toString('YYYY/MM/dd');

echo "Initial date ('dd/MM/YYYY'): ".$strInitialDate; echo "\n"; echo "Formatted date ('YYYY/MM/dd'): ".$strFormattedDate; echo "\n";

Thanks Philippe

Comments

Not reproduceable

Please give a full output like described within the FAQ and not only toString (dMY), otherwise it is not possible to reproduce your problem

Hi,

find enclosed a test file to reproduce the issue.

The output should be: Initial date ('dd/MM/YYYY'): 25/02/1824 Formatted date ('YYYY/MM/dd'): 1824/02/25

But actually, the output is:

Initial date ('dd/MM/YYYY'): 25/02/1824 Formatted date ('YYYY/MM/dd'): 1824/02/26

The problem occurs both in development and production environments.

Cordially Philippe

=======================

DEV ENVIRONMENT:

Windows Vista Home Premium Edition Service Pack 1) i586

PHP Version 5.3.0

PHP API: 20090626 PHP Extension: 20090626 Zend Extension: 220090626 Zend Extension Build: API220090626,TS,VC6 PHP Extension Build: API20090626,TS,VC6

PHP Info "related to date"

date/time support enabled "Olson" Timezone Database Version 2009.10 Timezone Database internal Default timezone UTC Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone UTC UTC

=======================

PRODUCTION ENVIRONMENT:

System: Linux ccwbnod06 2.6.18-164.11.1.el5 #1 SMP

PHP Version 5.3.2 PHP API: 20090626 PHP Extension: 20090626 Zend Extension: 220090626 Zend Extension Build: API220090626,NTS PHP Extension Build: API20090626,NTS

PHP Info "related to date":

date/time support enabled "Olson" Timezone Database Version 2010.3 Timezone Database internal Default timezone Europe/Berlin

Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone no value no value

Closing as not reproducable

Using your test example the result is:


Initial date ('dd/MM/YYYY'): 25/02/1824
Formatted date ('YYYY/MM/dd'): 1824/02/25

which is correct and shows no problem at all

So it's a complete mystery for me ...

In my two different environments, I still have the problem I described ..... ?! I've just tried with the 1.10.3 version, and I have the same result.

I also tried changing the way I construct the date, like this:

$datearray = array('year' => 1824, 'month' => 2, 'day' => 25); $myDate = new Zend_Date($datearray);

and the Zend_Date object still "considers" that the date is the 26 of February !!!!

A mystery ....

@Thomas: I think it could be something similar to ZF-9349. I reproduce his bug with 1.10.1 but not with current trunk.

@Mickael and Thomas: I confirm that the patch #21753 released for ZF-9349 solves the problem.

I didn't find it by myself: thank you Mickael, and sorry for disturbing !!! ;-)

Philippe