Skip to content

Commit

Permalink
[3.0.x] Fixed #31006 -- Doc'd backslash escaping in date/time templat…
Browse files Browse the repository at this point in the history
…e filters.

Backport of a1f14ee from master
  • Loading branch information
ryancheley authored and felixxm committed Dec 2, 2019
1 parent 3c370c1 commit cd7f48e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/ref/templates/builtins.txt
Expand Up @@ -1451,7 +1451,9 @@ used. Assuming the same settings as the previous example::
{{ value|date }}

outputs ``9 de Enero de 2008`` (the ``DATE_FORMAT`` format specifier for the
``es`` locale is ``r'j \d\e F \d\e Y'``.
``es`` locale is ``r'j \d\e F \d\e Y'``). Both "d" and "e" are
backslash-escaped, because otherwise each is a format string that displays the
day and the timezone name, respectively.

You can combine ``date`` with the :tfilter:`time` filter to render a full
representation of a ``datetime`` value. E.g.::
Expand Down Expand Up @@ -2172,6 +2174,15 @@ For example::
If ``value`` is equivalent to ``datetime.datetime.now()``, the output will be
the string ``"01:23"``.

Note that you can backslash-escape a format string if you want to use the
"raw" value. In this example, both "h" and "m" are backslash-escaped, because
otherwise each is a format string that displays the hour and the month,
respectively::

{% value|time:"H\h i\m" %}

This would display as "01h 23m".

Another example:

Assuming that :setting:`USE_L10N` is ``True`` and :setting:`LANGUAGE_CODE` is,
Expand Down

0 comments on commit cd7f48e

Please sign in to comment.