From: vitman Date: Thu, 25 Oct 2012 17:44:06 +0000 (+0300) Subject: Update lib/Twig/Extension/Core.php X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b89163df0cad982bde39970627b650cf58080f06;p=web%2Fkonrad%2Ftwig.git Update lib/Twig/Extension/Core.php --- diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index d436340..189bc0d 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -446,11 +446,12 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu { if (!$date instanceof DateTime) { $asString = (string) $date; - + $defaultTimeZone = $env->getExtension('core')->getTimezone(); + $defaultTimeZone = $defaultTimeZone !== null ? $defaultTimeZone : new DateTimeZone(date_default_timezone_get()); if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) { - $date = new DateTime('@'.$date); + $date = new DateTime('@'.$date, $defaultTimeZone); } else { - $date = new DateTime($date); + $date = new DateTime($date, $defaultTimeZone); } } else { $date = clone $date; @@ -463,10 +464,10 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu } else { $date->setTimezone(new DateTimeZone($timezone)); } - } elseif (($timezone = $env->getExtension('core')->getTimezone()) instanceof DateTimeZone) { - $date->setTimezone($timezone); + } elseif ($defaultTimeZone instanceof DateTimeZone) { + $date->setTimezone($defaultTimeZone); } else { - $date->setTimezone(new DateTimeZone(date_default_timezone_get())); + $date->setTimezone(new DateTimeZone($defaultTimeZone)); } return $date;