##// END OF EJS Templates
templates: provide granularity for future values for age filter
timeless -
r13666:c49cddce default
parent child Browse files
Show More
@@ -36,16 +36,22 b' def age(date):'
36
36
37 now = time.time()
37 now = time.time()
38 then = date[0]
38 then = date[0]
39 future = False
39 if then > now:
40 if then > now:
40 return 'in the future'
41 future = True
41
42 delta = max(1, int(then - now))
42 delta = max(1, int(now - then))
43 if delta > agescales[0][1] * 30:
43 if delta > agescales[0][1] * 2:
44 return 'in the distant future'
44 return util.shortdate(date)
45 else:
46 delta = max(1, int(now - then))
47 if delta > agescales[0][1] * 2:
48 return util.shortdate(date)
45
49
46 for t, s in agescales:
50 for t, s in agescales:
47 n = delta // s
51 n = delta // s
48 if n >= 2 or s == 1:
52 if n >= 2 or s == 1:
53 if future:
54 return '%s from now' % fmt(t, n)
49 return '%s ago' % fmt(t, n)
55 return '%s ago' % fmt(t, n)
50
56
51 def basename(path):
57 def basename(path):
@@ -1115,7 +1115,7 b' Filters work:'
1115 $ hg log --template '{date|age}\n' > /dev/null || exit 1
1115 $ hg log --template '{date|age}\n' > /dev/null || exit 1
1116
1116
1117 $ hg log -l1 --template '{date|age}\n'
1117 $ hg log -l1 --template '{date|age}\n'
1118 in the future
1118 8 years from now
1119 $ hg log --template '{date|date}\n'
1119 $ hg log --template '{date|date}\n'
1120 Wed Jan 01 10:01:00 2020 +0000
1120 Wed Jan 01 10:01:00 2020 +0000
1121 Mon Jan 12 13:46:40 1970 +0000
1121 Mon Jan 12 13:46:40 1970 +0000
General Comments 0
You need to be logged in to leave comments. Login now