Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 7682:9c8bbae02e9c
templater: fix age filter to state the obvious on future timestamps
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 22 Jan 2009 16:07:44 +0100 |
parents | 0dba955c2636 |
children | de377b1a9a84 |
comparison
equal
deleted
inserted
replaced
7681:c6f3ff294fe0 | 7682:9c8bbae02e9c |
---|---|
28 def fmt(t, c): | 28 def fmt(t, c): |
29 return "%d %s" % (c, plural(t, c)) | 29 return "%d %s" % (c, plural(t, c)) |
30 | 30 |
31 now = time.time() | 31 now = time.time() |
32 then = date[0] | 32 then = date[0] |
33 if then > now: | |
34 return 'in the future' | |
35 | |
33 delta = max(1, int(now - then)) | 36 delta = max(1, int(now - then)) |
34 | |
35 for t, s in agescales: | 37 for t, s in agescales: |
36 n = delta / s | 38 n = delta / s |
37 if n >= 2 or s == 1: | 39 if n >= 2 or s == 1: |
38 return fmt(t, n) | 40 return fmt(t, n) |
39 | 41 |