Browse Source

[ZF-7456] Zend_Date:

- fix for setting date with partitial array in leapyear day

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17612 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 years ago
parent
commit
844e57803e
2 changed files with 18 additions and 1 deletions
  1. 5 1
      library/Zend/Date.php
  2. 13 0
      tests/Zend/DateTest.php

+ 5 - 1
library/Zend/Date.php

@@ -197,7 +197,11 @@ class Zend_Date extends Zend_Date_DateObject
             $this->set($date, $part, $this->_locale);
 
             // DST fix
-            if ((is_array($date) === true) and (isset($date['hour']) === true)) {
+            if (is_array($date) === true) {
+                if (!isset($date['hour'])) {
+                    $date['hour'] = 0;
+                }
+
                 $hour = $this->toString('H');
                 $hour = $date['hour'] - $hour;
                 switch ($hour) {

+ 13 - 0
tests/Zend/DateTest.php

@@ -5462,6 +5462,19 @@ class Zend_DateTest extends PHPUnit_Framework_TestCase
         $this->assertTrue(Zend_Date::isDate("23/05/2010", "dd/MM/yyyy", "it_IT"));
         $this->assertTrue(Zend_Date::isDate("24/05/2010", "dd/MM/yyyy", "it_IT"));
     }
+
+    /**
+     * @ZF-7456
+     */
+    public function testSetArrayDateWithoutHour()
+    {
+        $date = new Zend_Date(array(
+            'year'=>2008,
+            'month'=>3,
+            'day'=>1)
+        );
+        $this->assertEquals('2008-03-01T00:00:00+01:00', $date->getIso());
+    }
 }
 
 class Zend_Date_TestHelper extends Zend_Date