From f6b90c8c2a8f1b3cea7bf9addbb041d3f1667511 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 9 Dec 2005 02:52:27 +0000 Subject: [PATCH] Fixed #977 -- Fixed timesince() utility. Thanks, pgross@thoughtworks.com git-svn-id: http://code.djangoproject.com/svn/django/trunk@1579 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 3 ++- django/utils/timesince.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 77f6240b44..052feaccf6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -75,8 +75,9 @@ answer newbie questions, and generally made Django that much better: Robin Munn Nebojša Dorđević Sam Newman - Luke Plant + pgross@thoughtworks.com phaedo + Luke Plant plisk Oliver Rutherfurd David Schein diff --git a/django/utils/timesince.py b/django/utils/timesince.py index 89af456e96..b9edb12554 100644 --- a/django/utils/timesince.py +++ b/django/utils/timesince.py @@ -4,7 +4,7 @@ from django.utils.translation import ngettext def timesince(d, now=None): """ - Takes a datetime object, returns the time between then and now + Takes two datetime objects and returns the time between then and now as a nicely formatted string, e.g "10 minutes" Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since """ @@ -16,7 +16,7 @@ def timesince(d, now=None): (60, lambda n: ngettext('minute', 'minutes', n)) ) if now: - t = time.mktime(now) + t = now.timetuple() else: t = time.localtime() if d.tzinfo: @@ -47,4 +47,4 @@ def timeuntil(d): the given time. """ now = datetime.datetime.now() - return timesince(now, time.mktime(d.timetuple())) + return timesince(now, d)