diff rhodecode/lib/utils2.py @ 3536:ed48d17836a4 beta

WIP: Changelog view
author Leonardo <leo@unity3d.com>
date Thu, 07 Mar 2013 14:48:23 +0100
parents 24ffe239e3d7
children 6e8027c2f49c
line wrap: on
line diff
--- a/rhodecode/lib/utils2.py	Thu Mar 07 14:38:40 2013 +0100
+++ b/rhodecode/lib/utils2.py	Thu Mar 07 14:48:23 2013 +0100
@@ -349,11 +349,15 @@
     return engine
 
 
-def age(prevdate):
+def age(prevdate, show_short_version=False):
     """
     turns a datetime into an age string.
+    If show_short_version is True, then it will generate a not so accurate but shorter string,
+    example: 2days ago, instead of 2 days and 23 hours ago.
+
 
     :param prevdate: datetime object
+    :param show_short_version: if it should aproximate the date and return a shorter string
     :rtype: unicode
     :returns: unicode words describing age
     """
@@ -423,7 +427,7 @@
         else:
             sub_value = 0
 
-        if sub_value == 0:
+        if sub_value == 0 or show_short_version:
             if future:
                 return _(u'in %s') % fmt_funcs[part](value)
             else: