Ticket #2063: date_hierarchy_i18n.diff

File date_hierarchy_i18n.diff, 2.6 KB (added by Ramiro Morales, 18 years ago)
  • django/contrib/admin/templatetags/admin_list.py

    diff -ruN dj-date-formats/django/contrib/admin/templatetags/admin_list.py dj-date-hierarchy-i18n/django/contrib/admin/templatetags/admin_list.py
    old new  
    88from django.utils import dateformat
    99from django.utils.html import escape
    1010from django.utils.text import capfirst
    11 from django.utils.translation import get_date_formats
     11from django.utils.translation import get_date_formats, get_partial_date_formats
    1212from django.template import Library
     13from datetime import MINYEAR, date
    1314
    1415register = Library()
    1516
     
    193194        year_lookup = cl.params.get(year_field)
    194195        month_lookup = cl.params.get(month_field)
    195196        day_lookup = cl.params.get(day_field)
     197        (year_month_format, month_day_format) = get_partial_date_formats()
    196198
    197199        link = lambda d: cl.get_query_string(d, [field_generic])
    198200
    199201        if year_lookup and month_lookup and day_lookup:
    200             month_name = MONTHS[int(month_lookup)]
     202            day = date(int(year_lookup), int(month_lookup), int(day_lookup))
    201203            return {
    202204                'show': True,
    203205                'back': {
    204206                    'link': link({year_field: year_lookup, month_field: month_lookup}),
    205                     'title': "%s %s" % (month_name, year_lookup)
     207                    'title': dateformat.format(day, year_month_format)
    206208                },
    207                 'choices': [{'title': "%s %s" % (month_name, day_lookup)}]
     209                'choices': [{'title': dateformat.format(day, month_day_format)}]
    208210            }
    209211        elif year_lookup and month_lookup:
    210212            days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day')
     
    216218                },
    217219                'choices': [{
    218220                    'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}),
    219                     'title': day.strftime('%B %d')
     221                    'title': dateformat.format(day, month_day_format)
    220222                } for day in days]
    221223            }
    222224        elif year_lookup:
     
    229231                },
    230232                'choices': [{
    231233                    'link': link({year_field: year_lookup, month_field: month.month}),
    232                     'title': "%s %s" % (month.strftime('%B'), month.year)
     234                    'title': dateformat.format(month, year_month_format)
    233235                } for month in months]
    234236            }
    235237        else:
Back to Top