From 4dee4e5841d1a59862b43ca8ed44a933f41e2024 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 15 Feb 2012 17:27:33 +0100 Subject: [PATCH] updated the CHANGELOG and documentation for previous merge --- CHANGELOG | 1 + doc/filters/date.rst | 16 +++++++++++++--- doc/functions/date.rst | 13 +++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 25eaac4..81cc594 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ * 1.7.0-DEV + * added a way to set the default global timezone for dates * fixed the slice filter on strings when the length is not specified * fixed the creation of the cache directory in case of a race condition diff --git a/doc/filters/date.rst b/doc/filters/date.rst index 60e94e2..f40ba94 100644 --- a/doc/filters/date.rst +++ b/doc/filters/date.rst @@ -7,6 +7,9 @@ .. versionadded:: 1.5 The default date format support has been added in Twig 1.5. +.. versionadded:: 1.7 + The default timezone support has been added in Twig 1.7. + The ``date`` filter formats a date to a given format: .. code-block:: jinja @@ -34,15 +37,22 @@ You can also specify a timezone: {{ post.published_at|date("m/d/Y", "Europe/Paris") }} If no format is provided, Twig will use the default one: ``F j, Y H:i``. This -default can be easily changed by calling the `setDateFormat()` method on the -`core` extension instance. The first argument is the default format for dates -and the second one is the default format for date intervals: +default can be easily changed by calling the ``setDateFormat()`` method on the +``core`` extension instance. The first argument is the default format for +dates and the second one is the default format for date intervals: .. code-block:: php $twig = new Twig_Environment($loader); $twig->getExtension('core')->setDateFormat('d/m/Y', '%d days'); +The default timezone can also be set globally by calling ``setTimezone()``: + +.. code-block:: php + + $twig = new Twig_Environment($loader); + $twig->getExtension('core')->setTimezone('Europe/Paris'); + .. _`date`: http://www.php.net/date .. _`DateTime`: http://www.php.net/DateTime .. _`DateInterval`: http://www.php.net/DateInterval diff --git a/doc/functions/date.rst b/doc/functions/date.rst index a8ab6bd..fc7c61e 100644 --- a/doc/functions/date.rst +++ b/doc/functions/date.rst @@ -4,6 +4,9 @@ .. versionadded:: 1.6 The date function has been added in Twig 1.6. +.. versionadded:: 1.7 + The default timezone support has been added in Twig 1.7. + Converts an argument to a date to allow date comparison: .. code-block:: jinja @@ -30,4 +33,14 @@ If no argument is passed, the function returns the current date: {# always! #} {% endif %} +.. note:: + + You can set the default timezone globally by calling ``setTimezone()`` on + the ``core`` extension instance: + + .. code-block:: php + + $twig = new Twig_Environment($loader); + $twig->getExtension('core')->setTimezone('Europe/Paris'); + .. _`date`: http://www.php.net/date -- 1.7.2.5