Ticket #6449: django-datetime-filter.2.patch
File django-datetime-filter.2.patch, 1.5 KB (added by , 17 years ago) |
---|
-
django/template/defaultfilters.py
614 614 # DATES # 615 615 ################### 616 616 617 def date (value, arg=None):618 """Formats a date according to the given format."""617 def datetime(value, arg=None): 618 """Formats a datetime according to the given format.""" 619 619 from django.utils.dateformat import format 620 620 if not value: 621 621 return u'' 622 622 if arg is None: 623 arg = settings.DATETIME_FORMAT 624 elif arg == 'x': 623 625 arg = settings.DATE_FORMAT 626 elif arg == 'X': 627 arg = settings.TIME_FORMAT 624 628 return format(value, arg) 629 datetime.is_safe = False 630 631 def date(value, arg=None): 632 """Formats a date according to the given format.""" 633 if arg is None: 634 arg = settings.DATE_FORMAT 635 return datetime(value, arg) 625 636 date.is_safe = False 626 637 627 638 def time(value, arg=None): 628 639 """Formats a time according to the given format.""" 629 from django.utils.dateformat import time_format630 if value in (None, u''):631 return u''632 640 if arg is None: 633 641 arg = settings.TIME_FORMAT 634 return time_format(value, arg)642 return datetime(value, arg) 635 643 time.is_safe = False 636 644 637 645 def timesince(value, arg=None): … … 797 805 register.filter(center) 798 806 register.filter(cut) 799 807 register.filter(date) 808 register.filter(datetime) 800 809 register.filter(default) 801 810 register.filter(default_if_none) 802 811 register.filter(dictsort)