Code

Ticket #9065: 9065-combined.diff

File 9065-combined.diff, 2.4 KB (added by mboersma, 5 years ago)

Combined diff file, updated against trunk [10088]

Line 
1Index: django/utils/timesince.py
2===================================================================
3--- django/utils/timesince.py   (revision 10088)
4+++ django/utils/timesince.py   (working copy)
5@@ -29,6 +29,9 @@
6     if d.__class__ is not datetime.datetime:
7         d = datetime.datetime(d.year, d.month, d.day)
8 
9+    if now and now.__class__ is not datetime.datetime:
10+        now = datetime.datetime(now.year, now.month, now.day)
11+
12     if not now:
13         if d.tzinfo:
14             now = datetime.datetime.now(LocalTimezone(d))
15Index: tests/regressiontests/templates/filters.py
16===================================================================
17--- tests/regressiontests/templates/filters.py  (revision 10088)
18+++ tests/regressiontests/templates/filters.py  (working copy)
19@@ -7,7 +7,7 @@
20 consistent.
21 """
22 
23-from datetime import datetime, timedelta
24+from datetime import date, datetime, timedelta
25 
26 from django.utils.tzinfo import LocalTimezone, FixedOffset
27 from django.utils.safestring import mark_safe
28@@ -28,6 +28,8 @@
29     now = datetime.now()
30     now_tz = datetime.now(LocalTimezone(now))
31     now_tz_i = datetime.now(FixedOffset((3 * 60) + 15)) # imaginary time zone
32+    today = date.today()
33+
34     return {
35         # Default compare with datetime.now()
36         'filter-timesince01' : ('{{ a|timesince }}', {'a': datetime.now() + timedelta(minutes=-1, seconds = -10)}, '1 minute'),
37@@ -55,6 +57,10 @@
38         'filter-timesince15' : ('{{ a|timesince:b }}', {'a': now, 'b': now_tz_i}, ''),
39         'filter-timesince16' : ('{{ a|timesince:b }}', {'a': now_tz_i, 'b': now}, ''),
40 
41+        # Regression for #9065
42+        'filter-timesince17' : ('{{ a|timesince:b }}', {'a': today, 'b': today}, '0 minutes'),
43+        'filter-timesince18' : ('{{ a|timesince:b }}', {'a': today, 'b': today + timedelta(hours=24)}, '1 day'),
44+       
45         # Default compare with datetime.now()
46         'filter-timeuntil01' : ('{{ a|timeuntil }}', {'a':datetime.now() + timedelta(minutes=2, seconds = 10)}, '2 minutes'),
47         'filter-timeuntil02' : ('{{ a|timeuntil }}', {'a':(datetime.now() + timedelta(days=1, seconds = 10))}, '1 day'),
48@@ -290,4 +296,3 @@
49         'join03': (r'{{ a|join:" & " }}', {'a': ['alpha', 'beta & me']}, 'alpha & beta & me'),
50         'join04': (r'{% autoescape off %}{{ a|join:" & " }}{% endautoescape %}', {'a': ['alpha', 'beta & me']}, 'alpha & beta & me'),
51     }
52-