Commits

Benoit Chesneau  committed 8d08b75

little reformat of timesince

  • Participants
  • Parent commits 8964e80

Comments (0)

Files changed (1)

File friendpaste/utils/__init__.py

 
     
 def timesince(d, now=None):
+    chunks = (
+      (60 * 60 * 24, lambda n : ungettext('day', 'days', n)),
+      (60 * 60, lambda n: ungettext('hour', 'hours', n)),
+      (60, lambda n: ungettext('minute', 'minutes', n))
+    )
     tz = None
     if d.__class__ is not datetime:
         type= d.__class__
     now = datetime(t[0], t[1], t[2], t[3], t[4], t[5], tzinfo=tz).utcnow()
     delta = now - (d - timedelta(0, 0, d.microsecond))
     since = delta.days * 24 * 60 * 60 + delta.seconds
-    chunks = (
-      (60 * 60 * 24, lambda n : ungettext('day', 'days', n)),
-      (60 * 60, lambda n: ungettext('hour', 'hours', n)),
-      (60, lambda n: ungettext('minute', 'minutes', n))
-    )
+    
     if since <= 0:
         # d is in the future compared to now, stop processing.
         return u'0 ' + ugettext('minutes ago')