From 3e7f5131a57f1606afb59ea4d86cac7a6005b969 Mon Sep 17 00:00:00 2001 From: Gary Wilson Jr Date: Mon, 30 Mar 2009 21:32:34 +0000 Subject: Fixed #9065 -- Fixed the `timesince` and `timeuntil` template tags to work when both values involved are date objects, thanks to morty and mboersma for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10215 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/timesince.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'django/utils') 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: -- cgit v1.3