#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)
Change History (3)
by , 19 years ago
Attachment: | timesince.patch added |
---|
comment:1 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Enable timesince with datetime.date