Issues

ZF-7745: setDayOfYear not working in a leap year

Description

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++) {
        $a->setDayOfYear($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?

And:

    $b = new Zend_Date(2008, Zend_Date::YEAR);
    $b->setDayOfYear(1);
    die($b);

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

Comments

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.