Opened 16 years ago

Closed 16 years ago

Last modified 14 years ago

#886 closed defect (fixed)

timesince breaks on the current time

Reported by: aaronsw Owned by: Adrian Holovaty
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: no UI/UX: no


    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.)

Change History (3)

comment:1 Changed 16 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 16 years ago by aaronsw

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

comment:3 Changed 16 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

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

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