summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/timesince.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/utils/timesince.py b/django/utils/timesince.py
index 1142e00d29..c584ce6981 100644
--- a/django/utils/timesince.py
+++ b/django/utils/timesince.py
@@ -25,9 +25,11 @@ def timesince(d, now=None):
(60 * 60, lambda n: ungettext('hour', 'hours', n)),
(60, lambda n: ungettext('minute', 'minutes', n))
)
- # Convert datetime.date to datetime.datetime for comparison
- if d.__class__ is not datetime.datetime:
+ # Convert datetime.date to datetime.datetime for comparison.
+ if not isinstance(d, datetime.datetime):
d = datetime.datetime(d.year, d.month, d.day)
+ if now and not isinstance(now, datetime.datetime):
+ now = datetime.datetime(now.year, now.month, now.day)
if not now:
if d.tzinfo: