From: Fabien Potencier Date: Fri, 24 Jun 2011 08:41:55 +0000 (+0200) Subject: added doc and fixed CS for previous merge X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8a5f6bf63b2c49dd1ca48c6f6e01b374e66ee16c;p=web%2Fkonrad%2Ftwig.git added doc and fixed CS for previous merge --- diff --git a/doc/templates.rst b/doc/templates.rst index 6dbc719..5f26722 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -1115,6 +1115,9 @@ List of built-in Filters ``date`` ~~~~~~~~ +.. versionadded:: 1.1 + The timezone support has been added in Twig 1.1. + The ``date`` filter is able to format a date to a given format: .. code-block:: jinja @@ -1135,6 +1138,10 @@ To escape words and characters in the date format use ``\\`` in front of each ch {{ post.published_at|date("F jS \\a\\t g:ia") }} +You can also specify a timezone: + + {{ post.published_at|date("m/d/Y", "Europe/Paris") }} + ``format`` ~~~~~~~~~~ diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index c5b2e1b..b65f732 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -201,7 +201,7 @@ class Twig_Extension_Core extends Twig_Extension } } -function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = NULL) +function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = null) { if (!$date instanceof DateTime) { if (ctype_digit((string) $date)) { @@ -212,7 +212,7 @@ function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = NULL } } - if ($timezone !== NULL) { + if (null !== $timezone) { if (!$timezone instanceof DateTimeZone) { $timezone = new DateTimeZone($timezone); }