Skip to content

Commit

Permalink
Fixed #977 -- Fixed timesince() utility. Thanks, pgross@thoughtworks.com
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1579 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Dec 9, 2005
1 parent d06a124 commit f6b90c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ answer newbie questions, and generally made Django that much better:
Robin Munn <http://www.geekforgod.com/> Robin Munn <http://www.geekforgod.com/>
Nebojša Dorđević Nebojša Dorđević
Sam Newman <http://www.magpiebrain.com/> Sam Newman <http://www.magpiebrain.com/>
Luke Plant <http://lukeplant.me.uk/> pgross@thoughtworks.com
phaedo <http://phaedo.cx/> phaedo <http://phaedo.cx/>
Luke Plant <http://lukeplant.me.uk/>
plisk plisk
Oliver Rutherfurd <http://rutherfurd.net/> Oliver Rutherfurd <http://rutherfurd.net/>
David Schein David Schein
Expand Down
6 changes: 3 additions & 3 deletions django/utils/timesince.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def timesince(d, now=None): 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" as a nicely formatted string, e.g "10 minutes"
Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since
""" """
Expand All @@ -16,7 +16,7 @@ def timesince(d, now=None):
(60, lambda n: ngettext('minute', 'minutes', n)) (60, lambda n: ngettext('minute', 'minutes', n))
) )
if now: if now:
t = time.mktime(now) t = now.timetuple()
else: else:
t = time.localtime() t = time.localtime()
if d.tzinfo: if d.tzinfo:
Expand Down Expand Up @@ -47,4 +47,4 @@ def timeuntil(d):
the given time. the given time.
""" """
now = datetime.datetime.now() now = datetime.datetime.now()
return timesince(now, time.mktime(d.timetuple())) return timesince(now, d)

0 comments on commit f6b90c8

Please sign in to comment.