diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-01-01 18:37:33 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-01-01 18:37:33 +0000 |
| commit | 53aef92bf89f2d655a125d94a0e24203e76af1d6 (patch) | |
| tree | 5aef7fe3213123da0526de9e02cfc0ed1b0dd51c /django/utils | |
| parent | 4596b1bbfdebcc367b51182b4c3e1bbaa6ba5631 (diff) | |
Fixed #1145 -- Added unit tests for default template filters and fixed two bugs in filters. Thanks, Luke Plant
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1811 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/timesince.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/django/utils/timesince.py b/django/utils/timesince.py index b9edb12554..0d1ab470e5 100644 --- a/django/utils/timesince.py +++ b/django/utils/timesince.py @@ -24,14 +24,16 @@ def timesince(d, now=None): else: tz = None now = datetime.datetime(t[0], t[1], t[2], t[3], t[4], t[5], tzinfo=tz) - delta = now - d + + # ignore microsecond part of 'd' since we removed it from 'now' + delta = now - (d - datetime.timedelta(0, 0, d.microsecond)) since = delta.days * 24 * 60 * 60 + delta.seconds for i, (seconds, name) in enumerate(chunks): count = since / seconds if count != 0: break if count < 0: - return '%d milliseconds' % math.floor(delta.microseconds / 1000) + return '%d milliseconds' % math.floor((now - d).microseconds / 1000) s = '%d %s' % (count, name(count)) if i + 1 < len(chunks): # Now get the second item |
