Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit f6b90c8c2a8f1b3cea7bf9addbb041d3f1667511 1 parent d06a124
Adrian Holovaty authored December 09, 2005
3  AUTHORS
@@ -75,8 +75,9 @@ answer newbie questions, and generally made Django that much better:
75 75
     Robin Munn <http://www.geekforgod.com/>
76 76
     Nebojša Dorđević
77 77
     Sam Newman <http://www.magpiebrain.com/>
78  
-    Luke Plant <http://lukeplant.me.uk/>
  78
+    pgross@thoughtworks.com
79 79
     phaedo <http://phaedo.cx/>
  80
+    Luke Plant <http://lukeplant.me.uk/>
80 81
     plisk
81 82
     Oliver Rutherfurd <http://rutherfurd.net/>
82 83
     David Schein
6  django/utils/timesince.py
@@ -4,7 +4,7 @@
4 4
 
5 5
 def timesince(d, now=None):
6 6
     """
7  
-    Takes a datetime object, returns the time between then and now
  7
+    Takes two datetime objects and returns the time between then and now
8 8
     as a nicely formatted string, e.g "10 minutes"
9 9
     Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since
10 10
     """
@@ -16,7 +16,7 @@ def timesince(d, now=None):
16 16
       (60, lambda n: ngettext('minute', 'minutes', n))
17 17
     )
18 18
     if now:
19  
-        t = time.mktime(now)
  19
+        t = now.timetuple()
20 20
     else:
21 21
         t = time.localtime()
22 22
     if d.tzinfo:
@@ -47,4 +47,4 @@ def timeuntil(d):
47 47
     the given time.
48 48
     """
49 49
     now = datetime.datetime.now()
50  
-    return timesince(now, time.mktime(d.timetuple()))
  50
+    return timesince(now, d)

0 notes on commit f6b90c8

Please sign in to comment.
Something went wrong with that request. Please try again.