[PATCH 2 of 2 RFC] templates: provide granularity for future values for age filter

timeless timeless at gmail.com
Tue Mar 15 21:35:59 CDT 2011


# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1300242536 -3600
# Node ID 3b123dd059fd577e1fbcb2b1ec80559157eae972
# Parent  d1b2d37302564f3638fe96478952e47778284b73
templates: provide granularity for future values for age filter

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -36,16 +36,22 @@ def age(date):
 
     now = time.time()
     then = date[0]
+    future = False
     if then > now:
-        return 'in the future'
-
-    delta = max(1, int(now - then))
-    if delta > agescales[0][1] * 2:
-        return util.shortdate(date)
+        future = True
+        delta = max(1, int(then - now))
+        if delta > agescales[0][1] * 30:
+            return 'in the distant future'
+    else:
+        delta = max(1, int(now - then))
+        if delta > agescales[0][1] * 2:
+            return util.shortdate(date)
 
     for t, s in agescales:
         n = delta // s
         if n >= 2 or s == 1:
+            if future:
+                return '%s from now' % fmt(t,n)
             return '%s ago' % fmt(t, n)
 
 def basename(path):


More information about the Mercurial-devel mailing list