Code

Opened 8 years ago

Closed 7 years ago

#2675 closed defect (fixed)

using timeuntil template filter on a past date results in random number of milliseconds

Reported by: Gary Wilson <gary.wilson@…> Owned by: nickefford
Component: Template system Version: master
Severity: normal Keywords: sprintsept14
Cc: gary.wilson@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

It should instead display "0 seconds" or something of the sort.

Attachments (2)

timesince.diff (2.4 KB) - added by nickefford 7 years ago.
Patch for django.utils.timesince and template docs
timesince.zip (943 bytes) - added by nickefford 7 years ago.
New tests for django.utils.timesince

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by Gary Wilson <gary.wilson@…>

  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by nickefford

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

comment:3 Changed 7 years ago by nickefford

Looking at django.utils.timesince, I discover that calling the timesince function on a time in the near future or the timeuntil function on a time in the near past both yield the result '-1 years 12 months'.

comment:4 Changed 7 years ago by nickefford

The attached patch fixes django.utils.timesince.timesince so that negative time intervals are rendered as "0 minutes", and amends the template documentation accordingly. I've added suitable tests, and these are provided as the attached zipfile. (Unzipping this file in the top-level directory should create a timesince directory under regressiontests.)

Changed 7 years ago by nickefford

Patch for django.utils.timesince and template docs

Changed 7 years ago by nickefford

New tests for django.utils.timesince

comment:5 Changed 7 years ago by nickefford

  • Has patch set

comment:6 Changed 7 years ago by nickefford

  • Keywords sprintsept14 added

comment:7 Changed 7 years ago by gwilson

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

(In [6366]) Fixed #2675 -- Changed the timeuntil and timesince template filters to display "0 minutes" when passed a past or future date respectively instead of "-1 years, 12 months". Thanks to nickefford for the patch.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.