diff --git a/src/Jasny/Twig/DateExtension.php b/src/Jasny/Twig/DateExtension.php index a660df8..7650117 100644 --- a/src/Jasny/Twig/DateExtension.php +++ b/src/Jasny/Twig/DateExtension.php @@ -75,7 +75,7 @@ protected function getFormat($format, $calendar=\IntlDateFormatter::GREGORIAN) */ protected function getDefaultDatePattern($calendar=\IntlDateFormatter::GREGORIAN) { - return preg_replace('/\byy?\b/', 'yyyy', \IntlDateFormatter::create(\Locale::getDefault(), \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, null, $calendar)->getPattern()); + return preg_replace('/\byy?\b/', 'yyyy', \IntlDateFormatter::create(\Locale::getDefault(), \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, \IntlTimeZone::getGMT(), $calendar)->getPattern()); } /** @@ -97,7 +97,7 @@ public function localDate($date, $format=null, $calendar='gregorian') $calendar = $calendar == 'traditional' ? \IntlDateFormatter::TRADITIONAL : \IntlDateFormatter::GREGORIAN; list($format, $pattern) = $this->getFormat($format, $calendar); - $df = new \IntlDateFormatter(\Locale::getDefault(), $format, \IntlDateFormatter::NONE, null, $calendar, $pattern); + $df = new \IntlDateFormatter(\Locale::getDefault(), $format, \IntlDateFormatter::NONE, \IntlTimeZone::getGMT(), $calendar, $pattern); return $df->format($date->getTimestamp()); } @@ -120,7 +120,7 @@ public function localTime($date, $format='short', $calendar='gregorian') $calendar = $calendar == 'traditional' ? \IntlDateFormatter::TRADITIONAL : \IntlDateFormatter::GREGORIAN; list($format, $pattern) = $this->getFormat($format, $calendar); - $df = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::NONE, $format, null, $calendar, $pattern); + $df = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::NONE, $format, \IntlTimeZone::getGMT(), $calendar, $pattern); return $df->format($date->getTimestamp()); } @@ -152,7 +152,7 @@ public function localDateTime($date, $format=null, $calendar='gregorian') list($format, $pattern) = $this->getFormat($format, $calendar); - $df = new \IntlDateFormatter(\Locale::getDefault(), $format, \IntlDateFormatter::SHORT, null, $calendar, $pattern); + $df = new \IntlDateFormatter(\Locale::getDefault(), $format, \IntlDateFormatter::SHORT, \IntlTimeZone::getGMT(), $calendar, $pattern); return $df->format($date->getTimestamp()); } diff --git a/tests/Jasny/Twig/ArrayExtensionTest.php b/tests/Jasny/Twig/ArrayExtensionTest.php index b180ee1..f52391a 100644 --- a/tests/Jasny/Twig/ArrayExtensionTest.php +++ b/tests/Jasny/Twig/ArrayExtensionTest.php @@ -2,15 +2,14 @@ namespace Jasny\Twig; -use Jasny\Twig\ArrayExtension; -class ArrayExtensionTest extends PHPUnit_Framework_TestCase { +class ArrayExtensionTest extends \PHPUnit_Framework_TestCase { private function buildEnv($template) { - $loader = new Twig_Loader_Array(array( + $loader = new \Twig_Loader_Array(array( 'template' => $template, )); - $twig = new Twig_Environment($loader); + $twig = new \Twig_Environment($loader); $twig->addExtension(new ArrayExtension()); return $twig; } diff --git a/tests/Jasny/Twig/DateExtensionTest.php b/tests/Jasny/Twig/DateExtensionTest.php index 37890e4..69cbbde 100644 --- a/tests/Jasny/Twig/DateExtensionTest.php +++ b/tests/Jasny/Twig/DateExtensionTest.php @@ -2,20 +2,19 @@ namespace Jasny\Twig; -use Jasny\Twig\DateExtension; -class DateExtensionTest extends PHPUnit_Framework_TestCase { +class DateExtensionTest extends \PHPUnit_Framework_TestCase { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - Locale::setDefault("en_CA"); + \Locale::setDefault("en_EN"); } private function buildEnv($template) { - $loader = new Twig_Loader_Array(array( + $loader = new \Twig_Loader_Array(array( 'template' => $template, )); - $twig = new Twig_Environment($loader); + $twig = new \Twig_Environment($loader); $twig->addExtension(new DateExtension()); return $twig; } @@ -48,7 +47,7 @@ public function testLocalTime() { } public function testLocalTimeLong() { - $this->check('11:14:12 PM PDT', "{{ '23:14:12'|localtime('long') }}"); + $this->check('11:14:12 PM GMT', "{{ '23:14:12'|localtime('long') }}"); } public function testLocalTimeShort() { diff --git a/tests/Jasny/Twig/PcreExtensionTest.php b/tests/Jasny/Twig/PcreExtensionTest.php index 9a2e08e..a636e07 100644 --- a/tests/Jasny/Twig/PcreExtensionTest.php +++ b/tests/Jasny/Twig/PcreExtensionTest.php @@ -2,15 +2,14 @@ namespace Jasny\Twig; -use Jasny\Twig\PcreExtension; -class PcreExtensionTest extends PHPUnit_Framework_TestCase { +class PcreExtensionTest extends \PHPUnit_Framework_TestCase { private function buildEnv($template) { - $loader = new Twig_Loader_Array(array( + $loader = new \Twig_Loader_Array(array( 'template' => $template, )); - $twig = new Twig_Environment($loader); + $twig = new \Twig_Environment($loader); $twig->addExtension(new PcreExtension()); return $twig; } @@ -43,7 +42,7 @@ public function testPregMatchNo() { } /** - * @expectedException Twig_Error_Runtime + * @expectedException \Twig_Error_Runtime */ public function testPregMatchError() { $this->check('NO', '{% if "fod"|preg_match("/o//o/") %}YES{% else %}NO{% endif %}'); diff --git a/tests/Jasny/Twig/TextExtensionTest.php b/tests/Jasny/Twig/TextExtensionTest.php index 84f7df8..b478349 100644 --- a/tests/Jasny/Twig/TextExtensionTest.php +++ b/tests/Jasny/Twig/TextExtensionTest.php @@ -2,15 +2,14 @@ namespace Jasny\Twig; -use Jasny\Twig\TextExtension; -class TextExtensionTest extends PHPUnit_Framework_TestCase { +class TextExtensionTest extends \PHPUnit_Framework_TestCase { private function buildEnv($template) { - $loader = new Twig_Loader_Array(array( + $loader = new \Twig_Loader_Array(array( 'template' => $template, )); - $twig = new Twig_Environment($loader); + $twig = new \Twig_Environment($loader); $twig->addExtension(new TextExtension()); return $twig; }