Django

Code

Changeset 3055

Show
Ignore:
Timestamp:
06/01/06 23:20:32 (2 years ago)
Author:
adrian
Message:

Fixed #2062 -- Added YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT settings, and added technical message IDs of the same names. Thanks, ramiro

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/conf/global_settings.py

    r3049 r3055  
    204204TIME_FORMAT = 'P' 
    205205 
     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 
     209YEAR_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 
     214MONTH_DAY_FORMAT = 'F j' 
     215 
    206216# Whether to enable Psyco, which optimizes Python code. Requires Psyco. 
    207217# http://psyco.sourceforge.net/ 
  • django/trunk/django/utils/translation.py

    r2927 r3055  
    222222    True = right-to-left layout 
    223223    """ 
    224      
     224 
    225225    from django.conf import settings 
    226226    return get_language() in settings.LANGUAGES_BIDI 
    227      
     227 
    228228def catalog(): 
    229229    """ 
     
    370370    if time_format == 'TIME_FORMAT': 
    371371        time_format = settings.TIME_FORMAT 
    372     return (date_format, datetime_format, time_format) 
     372    return date_format, datetime_format, time_format 
     373 
     374def 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 
    373388 
    374389def install(): 
  • django/trunk/docs/settings.txt

    r3049 r3055  
    292292`allowed date format strings`_. 
    293293 
    294 See also DATETIME_FORMAT and TIME_FORMAT. 
     294See also DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT. 
    295295 
    296296.. _allowed date format strings: http://www.djangoproject.com/documentation/templates/#now 
     
    305305`allowed date format strings`_. 
    306306 
    307 See also DATE_FORMAT and TIME_FORMAT. 
     307See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT. 
    308308 
    309309.. _allowed date format strings: http://www.djangoproject.com/documentation/templates/#now 
     
    533533A tuple of middleware classes to use. See the `middleware docs`_. 
    534534 
     535MONTH_DAY_FORMAT 
     536---------------- 
     537 
     538Default: ``'F j'`` 
     539 
     540The default formatting to use for date fields on Django admin change-list 
     541pages -- and, possibly, by other parts of the system -- in cases when only the 
     542month and day are displayed. 
     543 
     544For example, when a Django admin change-list page is being filtered by a date 
     545drilldown, the header for a given day displays the day and month. Different 
     546locales have different formats. For example, U.S. English would say 
     547"January 1," whereas Spanish might say "1 Enero." 
     548 
     549See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT, 
     550TIME_FORMAT and YEAR_MONTH_FORMAT. 
     551 
    535552PREPEND_WWW 
    536553----------- 
     
    697714`allowed date format strings`_. 
    698715 
    699 See also DATE_FORMAT and DATETIME_FORMAT. 
     716See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and 
     717MONTH_DAY_FORMAT. 
    700718 
    701719.. _allowed date format strings: http://www.djangoproject.com/documentation/templates/#now 
     
    720738bandwidth but slows down performance. This is only used if ``CommonMiddleware`` 
    721739is installed (see the `middleware docs`_). 
     740 
     741YEAR_MONTH_FORMAT 
     742----------------- 
     743 
     744Default: ``'F Y'`` 
     745 
     746The default formatting to use for date fields on Django admin change-list 
     747pages -- and, possibly, by other parts of the system -- in cases when only the 
     748year and month are displayed. 
     749 
     750For example, when a Django admin change-list page is being filtered by a date 
     751drilldown, the header for a given month displays the month and the year. 
     752Different locales have different formats. For example, U.S. English would say 
     753"January 2006," whereas another locale might say "2006/January." 
     754 
     755See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT, 
     756TIME_FORMAT and MONTH_DAY_FORMAT. 
    722757 
    723758.. _cache docs: http://www.djangoproject.com/documentation/cache/