Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13188 -- Moved date format documentation from the now template…

… tag to the date filter. Thanks, dwillis and timo.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14013 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 70e7e082fce39547b5bcca9a2a4044b008f1df4d 1 parent 58b704d
Jannis Leidel authored October 08, 2010

Showing 1 changed file with 81 additions and 78 deletions. Show diff stats Hide diff stats

  1. 159  docs/ref/templates/builtins.txt
159  docs/ref/templates/builtins.txt
@@ -644,75 +644,12 @@ See :doc:`Custom tag and filter libraries </howto/custom-template-tags>` for mor
644 644
 now
645 645
 ~~~
646 646
 
647  
-Display the date, formatted according to the given string.
  647
+Display the current date and/or time, according to the given string.
648 648
 
649  
-Uses the same format as PHP's ``date()`` function (http://php.net/date)
650  
-with some custom extensions.
651  
-
652  
-Available format strings:
653  
-
654  
-    ================  ========================================  =====================
655  
-    Format character  Description                               Example output
656  
-    ================  ========================================  =====================
657  
-    a                 ``'a.m.'`` or ``'p.m.'`` (Note that       ``'a.m.'``
658  
-                      this is slightly different than PHP's
659  
-                      output, because this includes periods
660  
-                      to match Associated Press style.)
661  
-    A                 ``'AM'`` or ``'PM'``.                     ``'AM'``
662  
-    b                 Month, textual, 3 letters, lowercase.     ``'jan'``
663  
-    B                 Not implemented.
664  
-    c                 ISO 8601 Format.                          ``2008-01-02T10:30:00.000123``
665  
-    d                 Day of the month, 2 digits with           ``'01'`` to ``'31'``
666  
-                      leading zeros.
667  
-    D                 Day of the week, textual, 3 letters.      ``'Fri'``
668  
-    f                 Time, in 12-hour hours and minutes,       ``'1'``, ``'1:30'``
669  
-                      with minutes left off if they're zero.
670  
-                      Proprietary extension.
671  
-    F                 Month, textual, long.                     ``'January'``
672  
-    g                 Hour, 12-hour format without leading      ``'1'`` to ``'12'``
673  
-                      zeros.
674  
-    G                 Hour, 24-hour format without leading      ``'0'`` to ``'23'``
675  
-                      zeros.
676  
-    h                 Hour, 12-hour format.                     ``'01'`` to ``'12'``
677  
-    H                 Hour, 24-hour format.                     ``'00'`` to ``'23'``
678  
-    i                 Minutes.                                  ``'00'`` to ``'59'``
679  
-    I                 Not implemented.
680  
-    j                 Day of the month without leading          ``'1'`` to ``'31'``
681  
-                      zeros.
682  
-    l                 Day of the week, textual, long.           ``'Friday'``
683  
-    L                 Boolean for whether it's a leap year.     ``True`` or ``False``
684  
-    m                 Month, 2 digits with leading zeros.       ``'01'`` to ``'12'``
685  
-    M                 Month, textual, 3 letters.                ``'Jan'``
686  
-    n                 Month without leading zeros.              ``'1'`` to ``'12'``
687  
-    N                 Month abbreviation in Associated Press    ``'Jan.'``, ``'Feb.'``, ``'March'``, ``'May'``
688  
-                      style. Proprietary extension.
689  
-    O                 Difference to Greenwich time in hours.    ``'+0200'``
690  
-    P                 Time, in 12-hour hours, minutes and       ``'1 a.m.'``, ``'1:30 p.m.'``, ``'midnight'``, ``'noon'``, ``'12:30 p.m.'``
691  
-                      'a.m.'/'p.m.', with minutes left off
692  
-                      if they're zero and the special-case
693  
-                      strings 'midnight' and 'noon' if
694  
-                      appropriate. Proprietary extension.
695  
-    r                 RFC 2822 formatted date.                  ``'Thu, 21 Dec 2000 16:01:07 +0200'``
696  
-    s                 Seconds, 2 digits with leading zeros.     ``'00'`` to ``'59'``
697  
-    S                 English ordinal suffix for day of the     ``'st'``, ``'nd'``, ``'rd'`` or ``'th'``
698  
-                      month, 2 characters.
699  
-    t                 Number of days in the given month.        ``28`` to ``31``
700  
-    T                 Time zone of this machine.                ``'EST'``, ``'MDT'``
701  
-    u                 Microseconds.                             ``0`` to ``999999``
702  
-    U                 Seconds since the Unix Epoch
703  
-                      (January 1 1970 00:00:00 UTC).
704  
-    w                 Day of the week, digits without           ``'0'`` (Sunday) to ``'6'`` (Saturday)
705  
-                      leading zeros.
706  
-    W                 ISO-8601 week number of year, with        ``1``, ``53``
707  
-                      weeks starting on Monday.
708  
-    y                 Year, 2 digits.                           ``'99'``
709  
-    Y                 Year, 4 digits.                           ``'1999'``
710  
-    z                 Day of the year.                          ``0`` to ``365``
711  
-    Z                 Time zone offset in seconds. The          ``-43200`` to ``43200``
712  
-                      offset for timezones west of UTC is
713  
-                      always negative, and for those east of
714  
-                      UTC is always positive.
715  
-    ================  ========================================  =====================
  649
+Given format can be one of the predefined ones ``DATE_FORMAT``,
  650
+``DATETIME_FORMAT``, ``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``,
  651
+or a custom format, same as the :tfilter:`date` filter. Note that predefined
  652
+formats may vary depending on the current locale.
716 653
 
717 654
 Example::
718 655
 
@@ -727,10 +664,6 @@ escaped, because it's not a format character::
727 664
 
728 665
 This would display as "It is the 4th of September".
729 666
 
730  
-.. versionadded:: 1.2
731  
-
732  
-The ``c`` and ``u`` format specification characters were added in Django 1.2.
733  
-
734 667
 .. templatetag:: regroup
735 668
 
736 669
 regroup
@@ -1138,10 +1071,77 @@ date
1138 1071
 
1139 1072
 Formats a date according to the given format.
1140 1073
 
1141  
-Given format can be one of the predefined ones ``DATE_FORMAT``,
1142  
-``DATETIME_FORMAT``, ``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``,
1143  
-or a custom format, same as the :ttag:`now` tag. Note that predefined formats
1144  
-may vary depending on the current locale.
  1074
+Uses the same format as PHP's ``date()`` function (http://php.net/date)
  1075
+with some custom extensions.
  1076
+
  1077
+Available format strings:
  1078
+
  1079
+    ================  ========================================  =====================
  1080
+    Format character  Description                               Example output
  1081
+    ================  ========================================  =====================
  1082
+    a                 ``'a.m.'`` or ``'p.m.'`` (Note that       ``'a.m.'``
  1083
+                      this is slightly different than PHP's
  1084
+                      output, because this includes periods
  1085
+                      to match Associated Press style.)
  1086
+    A                 ``'AM'`` or ``'PM'``.                     ``'AM'``
  1087
+    b                 Month, textual, 3 letters, lowercase.     ``'jan'``
  1088
+    B                 Not implemented.
  1089
+    c                 ISO 8601 Format.                          ``2008-01-02T10:30:00.000123``
  1090
+    d                 Day of the month, 2 digits with           ``'01'`` to ``'31'``
  1091
+                      leading zeros.
  1092
+    D                 Day of the week, textual, 3 letters.      ``'Fri'``
  1093
+    f                 Time, in 12-hour hours and minutes,       ``'1'``, ``'1:30'``
  1094
+                      with minutes left off if they're zero.
  1095
+                      Proprietary extension.
  1096
+    F                 Month, textual, long.                     ``'January'``
  1097
+    g                 Hour, 12-hour format without leading      ``'1'`` to ``'12'``
  1098
+                      zeros.
  1099
+    G                 Hour, 24-hour format without leading      ``'0'`` to ``'23'``
  1100
+                      zeros.
  1101
+    h                 Hour, 12-hour format.                     ``'01'`` to ``'12'``
  1102
+    H                 Hour, 24-hour format.                     ``'00'`` to ``'23'``
  1103
+    i                 Minutes.                                  ``'00'`` to ``'59'``
  1104
+    I                 Not implemented.
  1105
+    j                 Day of the month without leading          ``'1'`` to ``'31'``
  1106
+                      zeros.
  1107
+    l                 Day of the week, textual, long.           ``'Friday'``
  1108
+    L                 Boolean for whether it's a leap year.     ``True`` or ``False``
  1109
+    m                 Month, 2 digits with leading zeros.       ``'01'`` to ``'12'``
  1110
+    M                 Month, textual, 3 letters.                ``'Jan'``
  1111
+    n                 Month without leading zeros.              ``'1'`` to ``'12'``
  1112
+    N                 Month abbreviation in Associated Press    ``'Jan.'``, ``'Feb.'``, ``'March'``, ``'May'``
  1113
+                      style. Proprietary extension.
  1114
+    O                 Difference to Greenwich time in hours.    ``'+0200'``
  1115
+    P                 Time, in 12-hour hours, minutes and       ``'1 a.m.'``, ``'1:30 p.m.'``, ``'midnight'``, ``'noon'``, ``'12:30 p.m.'``
  1116
+                      'a.m.'/'p.m.', with minutes left off
  1117
+                      if they're zero and the special-case
  1118
+                      strings 'midnight' and 'noon' if
  1119
+                      appropriate. Proprietary extension.
  1120
+    r                 RFC 2822 formatted date.                  ``'Thu, 21 Dec 2000 16:01:07 +0200'``
  1121
+    s                 Seconds, 2 digits with leading zeros.     ``'00'`` to ``'59'``
  1122
+    S                 English ordinal suffix for day of the     ``'st'``, ``'nd'``, ``'rd'`` or ``'th'``
  1123
+                      month, 2 characters.
  1124
+    t                 Number of days in the given month.        ``28`` to ``31``
  1125
+    T                 Time zone of this machine.                ``'EST'``, ``'MDT'``
  1126
+    u                 Microseconds.                             ``0`` to ``999999``
  1127
+    U                 Seconds since the Unix Epoch
  1128
+                      (January 1 1970 00:00:00 UTC).
  1129
+    w                 Day of the week, digits without           ``'0'`` (Sunday) to ``'6'`` (Saturday)
  1130
+                      leading zeros.
  1131
+    W                 ISO-8601 week number of year, with        ``1``, ``53``
  1132
+                      weeks starting on Monday.
  1133
+    y                 Year, 2 digits.                           ``'99'``
  1134
+    Y                 Year, 4 digits.                           ``'1999'``
  1135
+    z                 Day of the year.                          ``0`` to ``365``
  1136
+    Z                 Time zone offset in seconds. The          ``-43200`` to ``43200``
  1137
+                      offset for timezones west of UTC is
  1138
+                      always negative, and for those east of
  1139
+                      UTC is always positive.
  1140
+    ================  ========================================  =====================
  1141
+
  1142
+.. versionadded:: 1.2
  1143
+
  1144
+The ``c`` and ``u`` format specification characters were added in Django 1.2.
1145 1145
 
1146 1146
 For example::
1147 1147
 
@@ -1151,7 +1151,10 @@ If ``value`` is a ``datetime`` object (e.g., the result of
1151 1151
 ``datetime.datetime.now()``), the output will be the string
1152 1152
 ``'Wed 09 Jan 2008'``.
1153 1153
 
1154  
-Another example:
  1154
+Given format can be one of the predefined ones ``DATE_FORMAT``,
  1155
+``DATETIME_FORMAT``, ``SHORT_DATE_FORMAT`` or ``SHORT_DATETIME_FORMAT``,
  1156
+or a custom format, same as the :ttag:`now` tag. Note that predefined formats
  1157
+may vary depending on the current locale.
1155 1158
 
1156 1159
 Assuming that :setting:`USE_L10N` is ``True`` and :setting:`LANGUAGE_CODE` is,
1157 1160
 for example, ``"es"``, then for::
@@ -1788,7 +1791,7 @@ time
1788 1791
 Formats a time according to the given format.
1789 1792
 
1790 1793
 Given format can be the predefined one ``TIME_FORMAT``, or a custom format,
1791  
-same as the :ttag:`now` tag. Note that the predefined format is locale-
  1794
+same as the :tfilter:`date` filter. Note that the predefined format is locale-
1792 1795
 dependant.
1793 1796
 
1794 1797
 The time filter will only accept parameters in the format string that relate

0 notes on commit 70e7e08

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