Opened 19 years ago

Closed 19 years ago

Last modified 17 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

Description

    from datetime import datetime
    from django.utils.timesince import timesince
    x = timesince(datetime.now())
    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 by aaronsw, 19 years ago

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

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

comment:2 by aaronsw, 19 years ago

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

comment:3 by Adrian Holovaty, 19 years ago

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