I'm writing a caledar script for managing orders. I want to implement an iCal
like interface for operators, so i created a calendar class; among its
methods I have two methods, getPreviousLink and getNextLink() that point to
previous and next month. When I create an object of this class, if no day
parameter is passed, I create an empty Zend_Date representig current date.
Howewer when I build links using Zend_Date::addMonth() and subMonth() I get
a very strange (for me) behaviour, i created some test code to reproduce the
problem:

                Zend_Debug::dump("adding months");
                $a = new Zend_Date();
                Zend_Debug::dump($a->toString());
                for ($i = 0; $i < 24; $i++) {
                        $a->addMonth(1);
                        Zend_Debug::dump($a->toString());
                }
                Zend_Debug::dump("subtracting months");
                $a = new Zend_Date();
                for ($i = 0; $i < 24; $i++) {
                        $a->subMonth(1);
                        Zend_Debug::dump($a->toString());
                }

the result for this code is: 

string(20) "29/giu/2008 20:56:13"

string(12) "adding months"
string(20) "01/lug/2008 20:56:13"
string(20) "01/lug/2008 20:56:13"
string(20) "01/lug/2008 20:56:13"
string(20) "01/lug/2008 20:56:13"
string(20) "01/lug/2008 20:56:13"
...
string(18) "subtracting months"
string(20) "01/mag/2008 21:02:38"
string(20) "01/mar/2008 21:02:38"
string(20) "01/gen/2008 21:02:38"
string(20) "01/nov/2007 21:02:38"
string(20) "01/set/2007 21:02:38"
string(20) "01/lug/2007 21:02:38"
string(20) "01/mag/2007 21:02:38"
string(20) "01/mar/2007 21:02:38"
...

Is this a bug or i misunderstood Zend_Date::add/subMonth() function?

Can anyone help me?

P.S. i've just upgraded to 1.5.2 ZF and my PHP version is 5.2.5


-- 
View this message in context: 
http://www.nabble.com/Zend_Date-problem-with-add-subMonth%28%29-tp18187205p18187205.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to