Ticket #11321: 11321-r11173.diff
File 11321-r11173.diff, 1.2 KB (added by , 15 years ago) |
---|
-
django/contrib/humanize/templatetags/humanize.py
2 2 from django.utils.encoding import force_unicode 3 3 from django import template 4 4 from django.template import defaultfilters 5 from datetime import date 5 from datetime import date, datetime 6 6 import re 7 7 8 8 register = template.Library() … … 80 80 present day returns representing string. Otherwise, returns a string 81 81 formatted according to settings.DATE_FORMAT. 82 82 """ 83 try: 83 try: 84 tzinfo = getattr(value, 'tzinfo', None) 84 85 value = date(value.year, value.month, value.day) 85 86 except AttributeError: 86 87 # Passed value wasn't a date object … … 88 89 except ValueError: 89 90 # Date arguments out of range 90 91 return value 91 delta = value - date.today() 92 delta = value - datetime.now(tzinfo).\ 93 replace(microsecond=0, second=0, minute=0, hour=0).date() 92 94 if delta.days == 0: 93 95 return _(u'today') 94 96 elif delta.days == 1: