Issues

ZF-10351: Zend_Date::addMonth() fails .. with Dates around midnight and timzone offset set , and certain values for month

Issue Type: Bug Created: 2010-08-20T08:20:58.000+0000 Last Updated: 2012-11-16T18:38:58.000+0000 Status: Open Fix version(s): Reporter: matthias frey (mathf) Assignee: Mason Malone (masonm) Tags: - Zend_Date

  • NeedsPatch

Related issues: Attachments:

Description

get(Zend\_Date::ISO\_8601); // 2010-08-20T00:00:00+02:00 $date->addMonth(3); echo "\\n".$date->get(Zend\_Date::ISO\_8601); // 2010-11-01T00:00:00+02:00 ?> The day is set to one.

To reproduce : date with 00:xx:xx , fails for addMonth() with values 3,4,5,6,7

Test case :

addMonth(3); $this->assertEquals('2010-11-20T00:00:00+01:00', $date->get(Zend\_Date::ISO\_8601)); /\* pass \*/ $date = new Zend\_Date('2010-08-20T00:00:00+02:00', Zend\_Date::ISO\_8601); $date->addMonth(2); $this->assertEquals('2010-10-20T00:00:00+02:00', $date->get(Zend\_Date::ISO\_8601)); /\* pass \*/ $date = new Zend\_Date('2010-08-20T04:00:00+02:00', Zend\_Date::ISO\_8601); $date->addMonth(3); $this->assertEquals('2010-11-20T04:00:00+02:00', $date->get(Zend\_Date::ISO\_8601)); /\* fail \*/ $date = new Zend\_Date('2010-08-20T00:00:00+02:00', Zend\_Date::ISO\_8601); $date->addMonth(3); $this->assertEquals('2010-11-20T00:00:00+02:00', $date->get(Zend\_Date::ISO\_8601)); } ?>

Comments

Posted by matthias frey (mathf) on 2010-08-30T02:37:39.000+0000

test case :

addMonth(3); $this->assertEquals('2010-11-20T00:00:00+01:00', $date->get(Zend\_Date::ISO\_8601)); // pass $date = new Zend\_Date('2010-08-20T00:00:00+02:00', Zend\_Date::ISO\_8601); $date->addMonth(2); $this->assertEquals('2010-10-20T00:00:00+02:00',$date->get(Zend\_Date::ISO\_8601)); // pass $date = new Zend\_Date('2010-08-20T04:00:00+02:00', Zend\_Date::ISO\_8601); $date->addMonth(3); $this->assertEquals('2010-11-20T04:00:00+02:00',$date->get(Zend\_Date::ISO\_8601)); // fail $date = new Zend\_Date('2010-08-20T00:00:00+02:00', Zend\_Date::ISO\_8601); $date->addMonth(3); $this->assertEquals('2010-11-20T00:00:00+02:00',$date->get(Zend\_Date::ISO\_8601)); } ?>

Posted by matthias frey (mathf) on 2010-08-30T02:38:36.000+0000

added a test case to illustrate the bug

Posted by matthias frey (mathf) on 2010-11-09T10:49:57.000+0000

any ideas/progress ? workarounds ? this is quite a show-stopper for me .. regards

Posted by matthias frey (mathf) on 2010-11-10T02:27:07.000+0000

It seems that setting "extend_month=true" in the Zend_Date options is a workaround

Posted by Mason Malone (masonm) on 2012-09-12T14:27:43.000+0000

Confirmed in ZF 1.12. Reproduction script: addMonth(3); var\_dump($a->getIso()); ?>

Output: string(25) "2012-05-01T00:00:00+01:00"

Posted by Frank Br├╝ckner (frosch) on 2012-09-12T14:39:23.000+0000

Hi Mason, can you write a patch and unit tests for this issue? The component maintainer Thomas no longer works for the ZF project.

Posted by Mason Malone (masonm) on 2012-09-12T14:41:01.000+0000

Okay, I'll give it a shot

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