added doc and fixed CS for previous merge

This commit is contained in:
Fabien Potencier
2011-06-24 10:41:55 +02:00
parent bbf55fe391
commit 8a5f6bf63b
2 changed files with 9 additions and 2 deletions
+7
View File
@@ -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``
~~~~~~~~~~
+2 -2
View File
@@ -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);
}