ZF-7154: Zend_Date::setMonth adds +1 Year when using abbreviated month name

Issue Type: Bug Created: 2009-06-28T17:42:29.000+0000 Last Updated: 2009-06-29T00:51:11.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

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

Related issues: Attachments:


Using shortnames for methods of Zend_Date which proxy the _month() method add +1 year.

<pre class="highlight">
$d0 = new Zend_Date();
$d1 = new Zend_Date();




* Output : 
* string(4) "2000"
* string(4) "2001"

I believe this to be due to the code in Zend/Date.php around line 3343 - 3355. It appears that arrays $monthlist and $monthlist2 are created, one containing full names, and then one containing abbreviated names. They are then merged together, and looped through to find a match. When a match is found $key + 1 is returned.

0-11 contain long names, January - December. 12-23 contain short names, Jan-Dec

So it seems that using short names results in a month number greater than 12, adding a year. I cannot determine if this was intentional, as code following the referenced block seems confusing to me, and much of Zend_Date is quite dense. This may perhaps be some function of localization that I am not recognizing?

<pre class="highlight">
*** Date.php    2009-06-28 20:18:29.000000000 -0400
--- Date.Fix.php    2009-06-28 20:18:48.000000000 -0400
*** 3346,3351 ****
--- 3346,3354 ----
                  foreach ($monthlist as $key => $value) {
                      if (strtoupper($value) == strtoupper($month)) {
                          $found = $key + 1;
+                       while($found > 12){
+                           $found = $found - 12;
+                       }


Posted by Thomas Weidner (thomas) on 2009-06-29T00:51:11.000+0000

Fixed with r16350

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.