Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1385 closed defect (fixed)

[PATCH] allow timesince filter to work with datetime.date objects

Reported by: matt Owned by: Adrian Holovaty
Component: Template system Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The timesince filter currently throws an AttributeError when applied to a datetime.date object:

'defaultfilters' module: API test raised an exception
=====================================================
Code: 'timesince(datetime.date.today() - datetime.timedelta(1))'
Line: 232
Exception:   File "/Users/mcroydon/django/django_src.trunk/tests/doctest.py", line 1243, in __run
    compileflags, 1) in test.globs
  File "<doctest defaultfilters[76]>", line 1, in ?
    timesince(datetime.date.today() - datetime.timedelta(1))
  File "/Users/mcroydon/django/django_src.trunk/django/core/template/defaultfilters.py", line 343, in timesince
    return timesince(value)
  File "/Users/mcroydon/django/django_src.trunk/django/utils/timesince.py", line 22, in timesince
    if d.tzinfo:
AttributeError: 'datetime.date' object has no attribute 'tzinfo'

The patch includes a test to confirm this behavior. The test passes after applying this patch.

Attachments (1)

timesince.patch (1.0 KB ) - added by matt 19 years ago.
Enable timesince with datetime.date

Download all attachments as: .zip

Change History (3)

by matt, 19 years ago

Attachment: timesince.patch added

Enable timesince with datetime.date

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [2375]) Fixed #1385 -- Allowed timesince filter to accept datetime.date objects. Thanks, Matt

comment:2 by (none), 18 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top