Ticket #11321: humanize_patch.txt

File humanize_patch.txt, 1.5 KB (added by aarond10, 15 years ago)

Patch to humanize.py

Line 
1*** old/django/contrib/humanize/templatetags/humanize.py 2008-07-21 15:20:54.000000000 +0000
2--- new/django/contrib/humanize/templatetags/humanize.py 2009-06-15 18:49:34.000000000 +0000
3***************
4*** 2,8 ****
5 from django.utils.encoding import force_unicode
6 from django import template
7 from django.template import defaultfilters
8! from datetime import date
9 import re
10
11 register = template.Library()
12--- 2,8 ----
13 from django.utils.encoding import force_unicode
14 from django import template
15 from django.template import defaultfilters
16! from datetime import date, datetime
17 import re
18
19 register = template.Library()
20***************
21*** 81,86 ****
22--- 81,87 ----
23 formatted according to settings.DATE_FORMAT.
24 """
25 try:
26+ tzinfo = value.tzinfo
27 value = date(value.year, value.month, value.day)
28 except AttributeError:
29 # Passed value wasn't a date object
30***************
31*** 88,94 ****
32 except ValueError:
33 # Date arguments out of range
34 return value
35! delta = value - date.today()
36 if delta.days == 0:
37 return _(u'today')
38 elif delta.days == 1:
39--- 89,95 ----
40 except ValueError:
41 # Date arguments out of range
42 return value
43! delta = value - datetime.now(tzinfo).replace(microsecond=0,second=0,minute=0,hour=0).date()
44 if delta.days == 0:
45 return _(u'today')
46 elif delta.days == 1:
Back to Top