Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #2062 -- Added YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT settings,…

… and added technical message IDs of the same names. Thanks, ramiro

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3055 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ab2fb1634f22d655ca38bd9ae7db9de3d1a629a3 1 parent 1717b94
Adrian Holovaty authored June 02, 2006
10  django/conf/global_settings.py
@@ -203,6 +203,16 @@
203 203
 # http://www.djangoproject.com/documentation/templates/#now
204 204
 TIME_FORMAT = 'P'
205 205
 
  206
+# Default formatting for date objects when only the year and month are relevant.
  207
+# See all available format strings here:
  208
+# http://www.djangoproject.com/documentation/templates/#now
  209
+YEAR_MONTH_FORMAT = 'F Y'
  210
+
  211
+# Default formatting for date objects when only the month and day are relevant.
  212
+# See all available format strings here:
  213
+# http://www.djangoproject.com/documentation/templates/#now
  214
+MONTH_DAY_FORMAT = 'F j'
  215
+
206 216
 # Whether to enable Psyco, which optimizes Python code. Requires Psyco.
207 217
 # http://psyco.sourceforge.net/
208 218
 ENABLE_PSYCO = False
21  django/utils/translation.py
@@ -221,10 +221,10 @@ def get_language_bidi():
221 221
     False = left-to-right layout
222 222
     True = right-to-left layout
223 223
     """
224  
-    
  224
+
225 225
     from django.conf import settings
226 226
     return get_language() in settings.LANGUAGES_BIDI
227  
-    
  227
+
228 228
 def catalog():
229 229
     """
230 230
     This function returns the current active catalog for further processing.
@@ -369,7 +369,22 @@ def get_date_formats():
369 369
         datetime_format = settings.DATETIME_FORMAT
370 370
     if time_format == 'TIME_FORMAT':
371 371
         time_format = settings.TIME_FORMAT
372  
-    return (date_format, datetime_format, time_format)
  372
+    return date_format, datetime_format, time_format
  373
+
  374
+def get_partial_date_formats():
  375
+    """
  376
+    This function checks whether translation files provide a translation for some
  377
+    technical message ID to store partial date formats. If it doesn't contain
  378
+    one, the formats provided in the settings will be used.
  379
+    """
  380
+    from django.conf import settings
  381
+    year_month_format = _('YEAR_MONTH_FORMAT')
  382
+    month_day_format = _('MONTH_DAY_FORMAT')
  383
+    if year_month_format == 'YEAR_MONTH_FORMAT':
  384
+        year_month_format = settings.YEAR_MONTH_FORMAT
  385
+    if month_day_format == 'MONTH_DAY_FORMAT':
  386
+        month_day_format = settings.MONTH_DAY_FORMAT
  387
+    return year_month_format, month_day_format
373 388
 
374 389
 def install():
375 390
     """
41  docs/settings.txt
@@ -291,7 +291,7 @@ The default formatting to use for date fields on Django admin change-list
291 291
 pages -- and, possibly, by other parts of the system. See
292 292
 `allowed date format strings`_.
293 293
 
294  
-See also DATETIME_FORMAT and TIME_FORMAT.
  294
+See also DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT.
295 295
 
296 296
 .. _allowed date format strings: http://www.djangoproject.com/documentation/templates/#now
297 297
 
@@ -304,7 +304,7 @@ The default formatting to use for datetime fields on Django admin change-list
304 304
 pages -- and, possibly, by other parts of the system. See
305 305
 `allowed date format strings`_.
306 306
 
307  
-See also DATE_FORMAT and TIME_FORMAT.
  307
+See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT.
308 308
 
309 309
 .. _allowed date format strings: http://www.djangoproject.com/documentation/templates/#now
310 310
 
@@ -532,6 +532,23 @@ Default::
532 532
 
533 533
 A tuple of middleware classes to use. See the `middleware docs`_.
534 534
 
  535
+MONTH_DAY_FORMAT
  536
+----------------
  537
+
  538
+Default: ``'F j'``
  539
+
  540
+The default formatting to use for date fields on Django admin change-list
  541
+pages -- and, possibly, by other parts of the system -- in cases when only the
  542
+month and day are displayed.
  543
+
  544
+For example, when a Django admin change-list page is being filtered by a date
  545
+drilldown, the header for a given day displays the day and month. Different
  546
+locales have different formats. For example, U.S. English would say
  547
+"January 1," whereas Spanish might say "1 Enero."
  548
+
  549
+See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT,
  550
+TIME_FORMAT and YEAR_MONTH_FORMAT.
  551
+
535 552
 PREPEND_WWW
536 553
 -----------
537 554
 
@@ -696,7 +713,8 @@ The default formatting to use for time fields on Django admin change-list
696 713
 pages -- and, possibly, by other parts of the system. See
697 714
 `allowed date format strings`_.
698 715
 
699  
-See also DATE_FORMAT and DATETIME_FORMAT.
  716
+See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and
  717
+MONTH_DAY_FORMAT.
700 718
 
701 719
 .. _allowed date format strings: http://www.djangoproject.com/documentation/templates/#now
702 720
 
@@ -720,6 +738,23 @@ A boolean that specifies whether to output the "Etag" header. This saves
720 738
 bandwidth but slows down performance. This is only used if ``CommonMiddleware``
721 739
 is installed (see the `middleware docs`_).
722 740
 
  741
+YEAR_MONTH_FORMAT
  742
+-----------------
  743
+
  744
+Default: ``'F Y'``
  745
+
  746
+The default formatting to use for date fields on Django admin change-list
  747
+pages -- and, possibly, by other parts of the system -- in cases when only the
  748
+year and month are displayed.
  749
+
  750
+For example, when a Django admin change-list page is being filtered by a date
  751
+drilldown, the header for a given month displays the month and the year.
  752
+Different locales have different formats. For example, U.S. English would say
  753
+"January 2006," whereas another locale might say "2006/January."
  754
+
  755
+See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT,
  756
+TIME_FORMAT and MONTH_DAY_FORMAT.
  757
+
723 758
 .. _cache docs: http://www.djangoproject.com/documentation/cache/
724 759
 .. _middleware docs: http://www.djangoproject.com/documentation/middleware/
725 760
 .. _session docs: http://www.djangoproject.com/documentation/sessions/

0 notes on commit ab2fb16

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