diff mercurial/templatefuncs.py @ 37226:67efce231633

templater: factor out function that parses argument as date tuple
author Yuya Nishihara <yuya@tcha.org>
date Sun, 18 Mar 2018 15:55:31 +0900
parents 2a2ce93e12f4
children e70a90a72b80
line wrap: on
line diff
--- a/mercurial/templatefuncs.py	Sun Mar 18 15:42:28 2018 +0900
+++ b/mercurial/templatefuncs.py	Sun Mar 18 15:55:31 2018 +0900
@@ -34,6 +34,7 @@
 evalrawexp = templateutil.evalrawexp
 evalfuncarg = templateutil.evalfuncarg
 evalboolean = templateutil.evalboolean
+evaldate = templateutil.evaldate
 evalinteger = templateutil.evalinteger
 evalstring = templateutil.evalstring
 evalstringliteral = templateutil.evalstringliteral
@@ -373,12 +374,9 @@
         # i18n: "localdate" is a keyword
         raise error.ParseError(_("localdate expects one or two arguments"))
 
-    date = evalfuncarg(context, mapping, args[0])
-    try:
-        date = dateutil.parsedate(date)
-    except AttributeError:  # not str nor date tuple
-        # i18n: "localdate" is a keyword
-        raise error.ParseError(_("localdate expects a date information"))
+    date = evaldate(context, mapping, args[0],
+                    # i18n: "localdate" is a keyword
+                    _("localdate expects a date information"))
     if len(args) >= 2:
         tzoffset = None
         tz = evalfuncarg(context, mapping, args[1])