Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added docs for changes in commit dd3a883.

Refs #20693.
  • Loading branch information...
commit bebb449ac334d7365a015b34b9c894dc4bf63f7f 1 parent 5a64f9b
Ramiro Morales authored September 22, 2013
29  docs/ref/templates/builtins.txt
@@ -1255,6 +1255,8 @@ with some differences.
1255 1255
     These format characters are not used in Django outside of templates. They
1256 1256
     were designed to be compatible with PHP to ease transitioning for designers.
1257 1257
 
  1258
+.. _date-and-time-formatting-specifiers:
  1259
+
1258 1260
 Available format strings:
1259 1261
 
1260 1262
 ================  ========================================  =====================
@@ -1338,7 +1340,7 @@ For example::
1338 1340
 
1339 1341
     {{ value|date:"D d M Y" }}
1340 1342
 
1341  
-If ``value`` is a ``datetime`` object (e.g., the result of
  1343
+If ``value`` is a :py:class:`~datetime.datetime` object (e.g., the result of
1342 1344
 ``datetime.datetime.now()``), the output will be the string
1343 1345
 ``'Wed 09 Jan 2008'``.
1344 1346
 
@@ -1363,6 +1365,11 @@ When used without a format string::
1363 1365
 ...the formatting string defined in the :setting:`DATE_FORMAT` setting will be
1364 1366
 used, without applying any localization.
1365 1367
 
  1368
+You can combine ``date`` with the :tfilter:`time` filter to render a full
  1369
+representation of a ``datetime`` value. E.g.::
  1370
+
  1371
+    {{ value|date:"D d M Y" }} {{ value|time:"H:i" }}
  1372
+
1366 1373
 .. templatefilter:: default
1367 1374
 
1368 1375
 default
@@ -2023,10 +2030,6 @@ Given format can be the predefined one :setting:`TIME_FORMAT`, or a custom
2023 2030
 format, same as the :tfilter:`date` filter. Note that the predefined format
2024 2031
 is locale-dependant.
2025 2032
 
2026  
-The time filter will only accept parameters in the format string that relate
2027  
-to the time of day, not the date (for obvious reasons). If you need to
2028  
-format a date, use the :tfilter:`date` filter.
2029  
-
2030 2033
 For example::
2031 2034
 
2032 2035
     {{ value|time:"H:i" }}
@@ -2044,6 +2047,17 @@ for example, ``"de"``, then for::
2044 2047
 the output will be the string ``"01:23:00"`` (The ``"TIME_FORMAT"`` format
2045 2048
 specifier for the ``de`` locale as shipped with Django is ``"H:i:s"``).
2046 2049
 
  2050
+The ``time`` filter will only accept parameters in the format string that
  2051
+relate to the time of day, not the date (for obvious reasons). If you need to
  2052
+format a ``date`` value, use the :tfilter:`date` filter instead (or along
  2053
+``time`` if you need to render a full :py:class:`~datetime.datetime` value).
  2054
+
  2055
+There is one exception the above rule: When passed a ``datetime`` value with
  2056
+attached timezone information (a :ref:`time-zone-aware
  2057
+<naive_vs_aware_datetimes>` ``datetime`` instance) the ``time`` filter will
  2058
+accept the timezone-related :ref:`format specifiers
  2059
+<date-and-time-formatting-specifiers>` ``'e'``, ``'O'`` , ``'T'`` and ``'Z'``.
  2060
+
2047 2061
 When used without a format string::
2048 2062
 
2049 2063
     {{ value|time }}
@@ -2051,6 +2065,11 @@ When used without a format string::
2051 2065
 ...the formatting string defined in the :setting:`TIME_FORMAT` setting will be
2052 2066
 used, without applying any localization.
2053 2067
 
  2068
+.. versionchanged:: 1.7
  2069
+
  2070
+    The ability to receive and act on values with attached timezone
  2071
+    information was added in Django 1.7.
  2072
+
2054 2073
 .. templatefilter:: timesince
2055 2074
 
2056 2075
 timesince
6  docs/releases/1.7.txt
@@ -301,6 +301,12 @@ Templates
301 301
   * :func:`django.shortcuts.render()`
302 302
   * :func:`django.shortcuts.render_to_response()`
303 303
 
  304
+* The :tfilter:`time` filter now accepts timzone-related :ref:`format
  305
+  specifiers <date-and-time-formatting-specifiers>` ``'e'``, ``'O'`` , ``'T'``
  306
+  and ``'Z'`` and is able to digest :ref:`time-zone-aware
  307
+  <naive_vs_aware_datetimes>` ``datetime`` instances performing the expected
  308
+  rendering.
  309
+
304 310
 Tests
305 311
 ^^^^^
306 312
 

0 notes on commit bebb449

Please sign in to comment.
Something went wrong with that request. Please try again.