Code

Ticket #13188: 13188.2.diff

File 13188.2.diff, 11.3 KB (added by timo, 4 years ago)
Line 
1Index: docs/ref/templates/builtins.txt
2===================================================================
3--- docs/ref/templates/builtins.txt     (revision 13686)
4+++ docs/ref/templates/builtins.txt     (working copy)
5@@ -638,76 +638,13 @@
6 now
7 ~~~
8 
9-Display the date, formatted according to the given string.
10+Display the current date and/or time, according to the given string.
11 
12-Uses the same format as PHP's ``date()`` function (http://php.net/date)
13-with some custom extensions.
14+Given format can be one of the predefined ones ``DATE_FORMAT``,
15+``DATETIME_FORMAT``, ``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``,
16+or a custom format, same as the :tfilter:`date` filter. Note that predefined formats
17+may vary depending on the current locale.
18 
19-Available format strings:
20-
21-    ================  ========================================  =====================
22-    Format character  Description                               Example output
23-    ================  ========================================  =====================
24-    a                 ``'a.m.'`` or ``'p.m.'`` (Note that       ``'a.m.'``
25-                      this is slightly different than PHP's
26-                      output, because this includes periods
27-                      to match Associated Press style.)
28-    A                 ``'AM'`` or ``'PM'``.                     ``'AM'``
29-    b                 Month, textual, 3 letters, lowercase.     ``'jan'``
30-    B                 Not implemented.
31-    c                 ISO 8601 Format.                          ``2008-01-02T10:30:00.000123``
32-    d                 Day of the month, 2 digits with           ``'01'`` to ``'31'``
33-                      leading zeros.
34-    D                 Day of the week, textual, 3 letters.      ``'Fri'``
35-    f                 Time, in 12-hour hours and minutes,       ``'1'``, ``'1:30'``
36-                      with minutes left off if they're zero.
37-                      Proprietary extension.
38-    F                 Month, textual, long.                     ``'January'``
39-    g                 Hour, 12-hour format without leading      ``'1'`` to ``'12'``
40-                      zeros.
41-    G                 Hour, 24-hour format without leading      ``'0'`` to ``'23'``
42-                      zeros.
43-    h                 Hour, 12-hour format.                     ``'01'`` to ``'12'``
44-    H                 Hour, 24-hour format.                     ``'00'`` to ``'23'``
45-    i                 Minutes.                                  ``'00'`` to ``'59'``
46-    I                 Not implemented.
47-    j                 Day of the month without leading          ``'1'`` to ``'31'``
48-                      zeros.
49-    l                 Day of the week, textual, long.           ``'Friday'``
50-    L                 Boolean for whether it's a leap year.     ``True`` or ``False``
51-    m                 Month, 2 digits with leading zeros.       ``'01'`` to ``'12'``
52-    M                 Month, textual, 3 letters.                ``'Jan'``
53-    n                 Month without leading zeros.              ``'1'`` to ``'12'``
54-    N                 Month abbreviation in Associated Press    ``'Jan.'``, ``'Feb.'``, ``'March'``, ``'May'``
55-                      style. Proprietary extension.
56-    O                 Difference to Greenwich time in hours.    ``'+0200'``
57-    P                 Time, in 12-hour hours, minutes and       ``'1 a.m.'``, ``'1:30 p.m.'``, ``'midnight'``, ``'noon'``, ``'12:30 p.m.'``
58-                      'a.m.'/'p.m.', with minutes left off
59-                      if they're zero and the special-case
60-                      strings 'midnight' and 'noon' if
61-                      appropriate. Proprietary extension.
62-    r                 RFC 2822 formatted date.                  ``'Thu, 21 Dec 2000 16:01:07 +0200'``
63-    s                 Seconds, 2 digits with leading zeros.     ``'00'`` to ``'59'``
64-    S                 English ordinal suffix for day of the     ``'st'``, ``'nd'``, ``'rd'`` or ``'th'``
65-                      month, 2 characters.
66-    t                 Number of days in the given month.        ``28`` to ``31``
67-    T                 Time zone of this machine.                ``'EST'``, ``'MDT'``
68-    u                 Microseconds.                             ``0`` to ``999999``
69-    U                 Seconds since the Unix Epoch
70-                      (January 1 1970 00:00:00 UTC).
71-    w                 Day of the week, digits without           ``'0'`` (Sunday) to ``'6'`` (Saturday)
72-                      leading zeros.
73-    W                 ISO-8601 week number of year, with        ``1``, ``53``
74-                      weeks starting on Monday.
75-    y                 Year, 2 digits.                           ``'99'``
76-    Y                 Year, 4 digits.                           ``'1999'``
77-    z                 Day of the year.                          ``0`` to ``365``
78-    Z                 Time zone offset in seconds. The          ``-43200`` to ``43200``
79-                      offset for timezones west of UTC is
80-                      always negative, and for those east of
81-                      UTC is always positive.
82-    ================  ========================================  =====================
83-
84 Example::
85 
86     It is {% now "jS F Y H:i" %}
87@@ -721,10 +658,6 @@
88 
89 This would display as "It is the 4th of September".
90 
91-.. versionadded:: 1.2
92-
93-The ``c`` and ``u`` format specification characters were added in Django 1.2.
94-
95 .. templatetag:: regroup
96 
97 regroup
98@@ -1132,11 +1065,78 @@
99 
100 Formats a date according to the given format.
101 
102-Given format can be one of the predefined ones ``DATE_FORMAT``,
103-``DATETIME_FORMAT``, ``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``,
104-or a custom format, same as the :ttag:`now` tag. Note that predefined formats
105-may vary depending on the current locale.
106+Uses the same format as PHP's ``date()`` function (http://php.net/date)
107+with some custom extensions.
108 
109+Available format strings:
110+
111+    ================  ========================================  =====================
112+    Format character  Description                               Example output
113+    ================  ========================================  =====================
114+    a                 ``'a.m.'`` or ``'p.m.'`` (Note that       ``'a.m.'``
115+                      this is slightly different than PHP's
116+                      output, because this includes periods
117+                      to match Associated Press style.)
118+    A                 ``'AM'`` or ``'PM'``.                     ``'AM'``
119+    b                 Month, textual, 3 letters, lowercase.     ``'jan'``
120+    B                 Not implemented.
121+    c                 ISO 8601 Format.                          ``2008-01-02T10:30:00.000123``
122+    d                 Day of the month, 2 digits with           ``'01'`` to ``'31'``
123+                      leading zeros.
124+    D                 Day of the week, textual, 3 letters.      ``'Fri'``
125+    f                 Time, in 12-hour hours and minutes,       ``'1'``, ``'1:30'``
126+                      with minutes left off if they're zero.
127+                      Proprietary extension.
128+    F                 Month, textual, long.                     ``'January'``
129+    g                 Hour, 12-hour format without leading      ``'1'`` to ``'12'``
130+                      zeros.
131+    G                 Hour, 24-hour format without leading      ``'0'`` to ``'23'``
132+                      zeros.
133+    h                 Hour, 12-hour format.                     ``'01'`` to ``'12'``
134+    H                 Hour, 24-hour format.                     ``'00'`` to ``'23'``
135+    i                 Minutes.                                  ``'00'`` to ``'59'``
136+    I                 Not implemented.
137+    j                 Day of the month without leading          ``'1'`` to ``'31'``
138+                      zeros.
139+    l                 Day of the week, textual, long.           ``'Friday'``
140+    L                 Boolean for whether it's a leap year.     ``True`` or ``False``
141+    m                 Month, 2 digits with leading zeros.       ``'01'`` to ``'12'``
142+    M                 Month, textual, 3 letters.                ``'Jan'``
143+    n                 Month without leading zeros.              ``'1'`` to ``'12'``
144+    N                 Month abbreviation in Associated Press    ``'Jan.'``, ``'Feb.'``, ``'March'``, ``'May'``
145+                      style. Proprietary extension.
146+    O                 Difference to Greenwich time in hours.    ``'+0200'``
147+    P                 Time, in 12-hour hours, minutes and       ``'1 a.m.'``, ``'1:30 p.m.'``, ``'midnight'``, ``'noon'``, ``'12:30 p.m.'``
148+                      'a.m.'/'p.m.', with minutes left off
149+                      if they're zero and the special-case
150+                      strings 'midnight' and 'noon' if
151+                      appropriate. Proprietary extension.
152+    r                 RFC 2822 formatted date.                  ``'Thu, 21 Dec 2000 16:01:07 +0200'``
153+    s                 Seconds, 2 digits with leading zeros.     ``'00'`` to ``'59'``
154+    S                 English ordinal suffix for day of the     ``'st'``, ``'nd'``, ``'rd'`` or ``'th'``
155+                      month, 2 characters.
156+    t                 Number of days in the given month.        ``28`` to ``31``
157+    T                 Time zone of this machine.                ``'EST'``, ``'MDT'``
158+    u                 Microseconds.                             ``0`` to ``999999``
159+    U                 Seconds since the Unix Epoch
160+                      (January 1 1970 00:00:00 UTC).
161+    w                 Day of the week, digits without           ``'0'`` (Sunday) to ``'6'`` (Saturday)
162+                      leading zeros.
163+    W                 ISO-8601 week number of year, with        ``1``, ``53``
164+                      weeks starting on Monday.
165+    y                 Year, 2 digits.                           ``'99'``
166+    Y                 Year, 4 digits.                           ``'1999'``
167+    z                 Day of the year.                          ``0`` to ``365``
168+    Z                 Time zone offset in seconds. The          ``-43200`` to ``43200``
169+                      offset for timezones west of UTC is
170+                      always negative, and for those east of
171+                      UTC is always positive.
172+    ================  ========================================  =====================
173+
174+.. versionadded:: 1.2
175+
176+The ``c`` and ``u`` format specification characters were added in Django 1.2.
177+
178 For example::
179 
180     {{ value|date:"D d M Y" }}
181@@ -1145,7 +1145,10 @@
182 ``datetime.datetime.now()``), the output will be the string
183 ``'Wed 09 Jan 2008'``.
184 
185-Another example:
186+Given format can be one of the predefined ones ``DATE_FORMAT``,
187+``DATETIME_FORMAT``, ``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``,
188+or a custom format, same as the :ttag:`now` tag. Note that predefined formats
189+may vary depending on the current locale.
190 
191 Assuming that :setting:`USE_L10N` is ``True`` and :setting:`LANGUAGE_CODE` is,
192 for example, ``"es"``, then for::
193@@ -1782,7 +1785,7 @@
194 Formats a time according to the given format.
195 
196 Given format can be the predefined one ``TIME_FORMAT``, or a custom format,
197-same as the :ttag:`now` tag. Note that the predefined format is locale-
198+same as the :tfilter:`date` filter. Note that the predefined format is locale-
199 dependant.
200 
201 The time filter will only accept parameters in the format string that relate