Django

Code

Ticket #886 (closed: fixed)

Opened 3 years ago

Last modified 1 year ago

timesince breaks on the current time

Reported by: aaronsw Assigned to: adrian
Milestone: Component: Tools
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Attachments

Change History

11/23/05 14:49:53 changed by aaronsw

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

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

11/23/05 14:53:06 changed by aaronsw

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

11/23/05 15:13:01 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #886 (timesince breaks on the current time)




Change Properties
Action