diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2009-03-30 21:32:34 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2009-03-30 21:32:34 +0000 |
| commit | 3e7f5131a57f1606afb59ea4d86cac7a6005b969 (patch) | |
| tree | ebdc8cc0175ac656d7a127a3167bcd7f9e1d6344 /django | |
| parent | 1f8c4ce60940deaf124eedc112fd9b5c1b317a4e (diff) | |
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
Diffstat (limited to 'django')
| -rw-r--r-- | django/utils/timesince.py | 6 |
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: |
