Mercurial > hg
comparison hgext/keyword.py @ 17755:bededd3f0735
templatefilters: avoid traceback caused by bogus date input (issue3344)
Wrap datefilters which split date texts with util.parsedate.
We do not abort, as the bogus date must have been given by the user.
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Fri, 10 Aug 2012 20:37:20 +0100 |
parents | e7cfe3587ea4 |
children | 434e5bd615fc |
comparison
equal
deleted
inserted
replaced
17754:19e9bf7c0927 | 17755:bededd3f0735 |
---|---|
115 | 115 |
116 # date like in cvs' $Date | 116 # date like in cvs' $Date |
117 def utcdate(text): | 117 def utcdate(text): |
118 ''':utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13". | 118 ''':utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13". |
119 ''' | 119 ''' |
120 return util.datestr((text[0], 0), '%Y/%m/%d %H:%M:%S') | 120 return util.datestr((util.parsedate(text)[0], 0), '%Y/%m/%d %H:%M:%S') |
121 # date like in svn's $Date | 121 # date like in svn's $Date |
122 def svnisodate(text): | 122 def svnisodate(text): |
123 ''':svnisodate: Date. Returns a date in this format: "2009-08-18 13:00:13 | 123 ''':svnisodate: Date. Returns a date in this format: "2009-08-18 13:00:13 |
124 +0200 (Tue, 18 Aug 2009)". | 124 +0200 (Tue, 18 Aug 2009)". |
125 ''' | 125 ''' |
127 # date like in svn's $Id | 127 # date like in svn's $Id |
128 def svnutcdate(text): | 128 def svnutcdate(text): |
129 ''':svnutcdate: Date. Returns a UTC-date in this format: "2009-08-18 | 129 ''':svnutcdate: Date. Returns a UTC-date in this format: "2009-08-18 |
130 11:00:13Z". | 130 11:00:13Z". |
131 ''' | 131 ''' |
132 return util.datestr((text[0], 0), '%Y-%m-%d %H:%M:%SZ') | 132 return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ') |
133 | 133 |
134 templatefilters.filters.update({'utcdate': utcdate, | 134 templatefilters.filters.update({'utcdate': utcdate, |
135 'svnisodate': svnisodate, | 135 'svnisodate': svnisodate, |
136 'svnutcdate': svnutcdate}) | 136 'svnutcdate': svnutcdate}) |
137 | 137 |