Issues

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

Issue Type: Bug Created: 2010-04-19T09:55:29.000+0000 Last Updated: 2010-04-22T03:36:54.000+0000 Status: Resolved Fix version(s): - 1.10.4 (28/Apr/10)

Reporter: stabiloo (stabiloo) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date

Related issues: - ZF-9349

Attachments: - test.php

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:

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 Posted by Thomas Weidner (thomas) on 2010-04-19T10:55:23.000+0000 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 Posted by stabiloo (stabiloo) on 2010-04-20T03:09:41.000+0000 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 Posted by Thomas Weidner (thomas) on 2010-04-20T13:04:29.000+0000 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

 

 

Posted by stabiloo (stabiloo) on 2010-04-21T08:32:32.000+0000

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 ....

 

 

Posted by Mickael Perraud (mikaelkael) on 2010-04-21T12:09:54.000+0000

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

 

 

Posted by stabiloo (stabiloo) on 2010-04-22T03:36:53.000+0000

@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

 

 
        

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts