ZF-7745: setDayOfYear not working in a leap year

Issue Type: Bug Created: 2009-09-01T03:07:01.000+0000 Last Updated: 2009-09-01T04:06:17.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

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

Related issues: Attachments:


I found a bug in Zend Date. If I create an object related to a leap year, when I call setDayOfYear in a for cicle, I loose the second of March.

    $a = new Zend_Date(2008, Zend_Date::YEAR);
    echo $a;

returns: 01/gen/2008 00.00.00 (it's ok!)

then, I tried to run this code:

    for ($i=32; $i<65; $i++) {
        echo $a->toString(Zend_Date::DAY ."-". Zend_Date::MONTH);
        echo(" ($i) <br>");

I get: 01/02 (32) 02/02 (33) 03/02 (34) ..... 26/02 (57) 27/02 (58) 28/02 (59) 29/02 (60) 01/03 (61) 03/03 (62) 04/03 (63) 05/03 (64)

Where is gone March 2nd?

By the way, if I call this method not in the for the result is correct. Can you confirm?


    $b = new Zend_Date(2008, Zend_Date::YEAR);

is: 02/gen/2008 23.00.00

But: $c = new Zend_Date(2009, Zend_Date::YEAR); $c->setDayOfYear(1); die($c); is: 01/gen/2009 23.00.00

Why? (I don't know it these things are related.)


Posted by Thomas Weidner (thomas) on 2009-09-01T04:06:12.000+0000

Issue not related special to leap year, but to the problem that only the year has been set and the other date parts are in an undefined state.

Fixed with r17944 for 1.10.

Have you found an issue?

See the Overview section for more details.


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

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