Jelajahi Sumber

[Locale] use UTC if timezone is unsupported

Igor Wiedler 14 tahun lalu
induk
melakukan
632ded5c96

+ 5 - 1
src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php

@@ -40,7 +40,11 @@ class StubIntlDateFormatter
 
         $this->setPattern($pattern);
 
-        $this->dateTimeZone = new \DateTimeZone($timezone);
+        try {
+            $this->dateTimeZone = new \DateTimeZone($timezone);
+        } catch (\Exception $e) {
+            $this->dateTimeZone = new \DateTimeZone('UTC');
+        }
     }
 
     public function format($timestamp)

+ 2 - 0
tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php

@@ -216,6 +216,8 @@ class StubIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
             array(0, 'Europe/Dublin', '1970-01-01 01:00:00'),
             array(0, 'Europe/Warsaw', '1970-01-01 01:00:00'),
             array(0, 'Pacific/Fiji', '1970-01-01 12:00:00'),
+
+            array(0, 'Foo/Bar', '1970-01-01 00:00:00'),
         );
     }