Просмотр исходного кода

ZF-11846: Extend allowed UTC offset to UTC+14

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24812 44c647ce-9c0f-0410-b52a-842ac1e357ba
adamlundrigan 13 лет назад
Родитель
Сommit
a161f20560
2 измененных файлов с 11 добавлено и 1 удалено
  1. 1 1
      library/Zend/Date.php
  2. 10 0
      tests/Zend/DateTest.php

+ 1 - 1
library/Zend/Date.php

@@ -1201,7 +1201,7 @@ class Zend_Date extends Zend_Date_DateObject
         }
         }
 
 
         preg_match('/([+-]\d{2}):{0,1}\d{2}/', $zone, $match);
         preg_match('/([+-]\d{2}):{0,1}\d{2}/', $zone, $match);
-        if (!empty($match) and ($match[count($match) - 1] <= 12) and ($match[count($match) - 1] >= -12)) {
+        if (!empty($match) and ($match[count($match) - 1] <= 14) and ($match[count($match) - 1] >= -12)) {
             $zone = "Etc/GMT";
             $zone = "Etc/GMT";
             $zone .= ($match[count($match) - 1] < 0) ? "+" : "-";
             $zone .= ($match[count($match) - 1] < 0) ? "+" : "-";
             $zone .= (int) abs($match[count($match) - 1]);
             $zone .= (int) abs($match[count($match) - 1]);

+ 10 - 0
tests/Zend/DateTest.php

@@ -5679,6 +5679,16 @@ class Zend_DateTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($t, $date->toString('yyyy-MM-dd HH:mm:ss'));
         $this->assertEquals($t, $date->toString('yyyy-MM-dd HH:mm:ss'));
     }
     }
 
 
+    /**
+     * @group ZF-11846
+     */
+    public function testGetTimezoneFromStringForTimezoneOffsetsGreaterThan12()
+    {
+        $date = new Zend_Date();
+        $this->assertEquals('Etc/GMT-13', $date->getTimezoneFromString('18:00:00+1300'));
+        $this->assertEquals('Etc/GMT-14', $date->getTimezoneFromString('18:00:00+1400'));
+    }
+
 }
 }
 
 
 class Zend_Date_TestHelper extends Zend_Date
 class Zend_Date_TestHelper extends Zend_Date