Opened 9 years ago

Closed 9 years ago

Last modified 8 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:

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 Changed 9 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 9 years ago by aaronsw

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

comment:3 Changed 9 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

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