From b89163df0cad982bde39970627b650cf58080f06 Mon Sep 17 00:00:00 2001 From: vitman Date: Thu, 25 Oct 2012 20:44:06 +0300 Subject: [PATCH] Update lib/Twig/Extension/Core.php --- lib/Twig/Extension/Core.php | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) 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; -- 1.7.2.5