Opened 7 years ago

Closed 6 years ago

Last modified 4 years ago

#9065 closed (fixed)

timesince filter not calculating difference between two dates

Reported by: rcornish Owned by: gwilson
Component: Template system Version: 1.0
Severity: Keywords: template, filter, timesince
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

My template code is:

{% with publication.list|last as oldest %}
{% with publication.list|first as newest %}

{{ newest.date|timesince:oldest.date }}

{% endwith %}{% endwith %}

It calculated the dates between the newest and oldest entries. It worked before 1.0, and now it doesn't. {{ newest.date}} and {{ oldest.date }} by themselves both return dates. Help. :(

Attachments (3)

9065-fix.diff (532 bytes) - added by morty 7 years ago.
Patch
9065-tests.diff (1.6 KB) - added by morty 7 years ago.
9065-combined.diff (2.4 KB) - added by mboersma 6 years ago.
Combined diff file, updated against trunk [10088]

Download all attachments as: .zip

Change History (12)

comment:1 Changed 7 years ago by morty

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

The timesince function converts instances of Date to DateTime before doing the calculation. The from value is converted, but the to value is not. I am attaching a patch to fix this bug.

Changed 7 years ago by morty

Patch

Changed 7 years ago by morty

comment:2 Changed 7 years ago by alexr

  • Has patch set

Just noticed there was a patch but "Has patch" wasn't set.

comment:3 Changed 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:4 Changed 7 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

Changed 6 years ago by mboersma

Combined diff file, updated against trunk [10088]

comment:5 Changed 6 years ago by mboersma

  • Triage Stage changed from Accepted to Ready for checkin

I applied the patch and re-tested against django-trunk.

comment:6 Changed 6 years ago by gwilson

  • Owner changed from nobody to gwilson
  • Status changed from new to assigned

comment:7 Changed 6 years ago by gwilson

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [10215]) 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.

comment:8 Changed 6 years ago by gwilson

(In [10216]) [1.0.X]: 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.

Backport of r10215 from trunk.

comment:9 Changed 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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