Mercurial > hg-stable
diff mercurial/templatefilters.py @ 13666:c49cddce0a81
templates: provide granularity for future values for age filter
author | timeless <timeless@gmail.com> |
---|---|
date | Wed, 16 Mar 2011 03:28:56 +0100 |
parents | cc4721ed7a2a |
children | 7a6a8a069aac |
line wrap: on
line diff
--- a/mercurial/templatefilters.py Wed Mar 16 23:09:14 2011 +0100 +++ b/mercurial/templatefilters.py Wed Mar 16 03:28:56 2011 +0100 @@ -36,16 +36,22 @@ 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):