summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-23 21:13:00 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-23 21:13:00 +0000
commitfce688cc743bd77c8e415c5a7a409b5fe211e6f7 (patch)
tree6a0d6497bca4c6768cb4ffd67c1bcef6fc39f4fa
parent87e0c2a712c9c63af81d571d0e163150575e769a (diff)
Fixed #886 -- timesince utility now supports microseconds. Thanks, Aaron Swartz
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1374 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/utils/timesince.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/utils/timesince.py b/django/utils/timesince.py
index b1df997e2e..89af456e96 100644
--- a/django/utils/timesince.py
+++ b/django/utils/timesince.py
@@ -1,4 +1,4 @@
-import datetime, time
+import datetime, math, time
from django.utils.tzinfo import LocalTimezone
from django.utils.translation import ngettext
@@ -30,6 +30,8 @@ def timesince(d, now=None):
count = since / seconds
if count != 0:
break
+ if count < 0:
+ return '%d milliseconds' % math.floor(delta.microseconds / 1000)
s = '%d %s' % (count, name(count))
if i + 1 < len(chunks):
# Now get the second item