Mercurial > hg
changeset 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 | 19e9bf7c0927 |
children | 92980a8dfdfe |
files | hgext/keyword.py mercurial/templatefilters.py |
diffstat | 2 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/keyword.py Mon Aug 13 22:42:10 2012 +0200 +++ b/hgext/keyword.py Fri Aug 10 20:37:20 2012 +0100 @@ -117,7 +117,7 @@ def utcdate(text): ''':utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13". ''' - return util.datestr((text[0], 0), '%Y/%m/%d %H:%M:%S') + return util.datestr((util.parsedate(text)[0], 0), '%Y/%m/%d %H:%M:%S') # date like in svn's $Date def svnisodate(text): ''':svnisodate: Date. Returns a date in this format: "2009-08-18 13:00:13 @@ -129,7 +129,7 @@ ''':svnutcdate: Date. Returns a UTC-date in this format: "2009-08-18 11:00:13Z". ''' - return util.datestr((text[0], 0), '%Y-%m-%d %H:%M:%SZ') + return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ') templatefilters.filters.update({'utcdate': utcdate, 'svnisodate': svnisodate,
--- a/mercurial/templatefilters.py Mon Aug 13 22:42:10 2012 +0200 +++ b/mercurial/templatefilters.py Fri Aug 10 20:37:20 2012 +0100 @@ -221,7 +221,7 @@ def localdate(text): """:localdate: Date. Converts a date to local date.""" - return (text[0], util.makedate()[1]) + return (util.parsedate(text)[0], util.makedate()[1]) def nonempty(str): """:nonempty: Any text. Returns '(none)' if the string is empty."""