Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#886 closed defect (fixed)

timesince breaks on the current time

Reported by: aaronsw Owned by: adrian
Component: Tools Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


    from datetime import datetime
    from django.utils.timesince import timesince
    x = timesince(
    assert x == "-1 years, 12 months"

I think it should return "12 miliseconds", or at least "0 seconds". (The former would be much more entertaining, though.)

Attachments (0)

Change History (3)

comment:1 Changed 8 years ago by aaronsw

The fix is to add these lines before if count == 1:

    if count < 0:
        return '%d milliseconds' % math.floor(delta.microseconds / 100)

comment:2 Changed 8 years ago by aaronsw

Oops, there should be an extra 0 at the end of that 100.

comment:3 Changed 8 years ago by adrian

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

(In [1374]) Fixed #886 -- timesince utility now supports microseconds. Thanks, Aaron Swartz

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.