Ticket #9366: datefilters.diff
File datefilters.diff, 1.6 KB (added by , 16 years ago) |
---|
-
django/template/defaultfilters.py
9 9 10 10 from django.template import Variable, Library 11 11 from django.conf import settings 12 from django.utils.translation import ugettext, ungettext 12 from django.utils.translation import ugettext, ungettext, get_date_formats 13 13 from django.utils.encoding import force_unicode, iri_to_uri 14 14 from django.utils.safestring import mark_safe, SafeData 15 15 … … 627 627 if not value: 628 628 return u'' 629 629 if arg is None: 630 arg = settings.DATE_FORMAT630 arg = get_date_formats()[0] 631 631 return format(value, arg) 632 632 date.is_safe = False 633 633 634 def datetime(value, arg=None): 635 """Formats a date and time according to the given format.""" 636 from django.utils.dateformat import format 637 if not value: 638 return u'' 639 if arg is None: 640 arg = get_date_formats()[1] 641 return format(value, arg) 642 datetime.is_safe = False 643 634 644 def time(value, arg=None): 635 645 """Formats a time according to the given format.""" 636 646 from django.utils.dateformat import time_format 637 647 if value in (None, u''): 638 648 return u'' 639 649 if arg is None: 640 arg = settings.TIME_FORMAT650 arg = get_date_formats()[2] 641 651 return time_format(value, arg) 642 652 time.is_safe = False 643 653 … … 808 818 register.filter(center) 809 819 register.filter(cut) 810 820 register.filter(date) 821 register.filter(datetime) 811 822 register.filter(default) 812 823 register.filter(default_if_none) 813 824 register.filter(dictsort)