changeset 37230:a0b17f744cbc

keyword: declare input type of date filters as date Dropped redundant dateutil.parsedate(), which is now handled by the templater.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 18 Mar 2018 17:02:39 +0900
parents 9bcf096a2da2
children 05db42732fce
files hgext/keyword.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/keyword.py	Sun Mar 18 16:12:44 2018 +0900
+++ b/hgext/keyword.py	Sun Mar 18 17:02:39 2018 +0900
@@ -109,6 +109,7 @@
     registrar,
     scmutil,
     templatefilters,
+    templateutil,
     util,
 )
 from mercurial.utils import (
@@ -156,27 +157,27 @@
     default=False,
 )
 # date like in cvs' $Date
-@templatefilter('utcdate')
-def utcdate(text):
+@templatefilter('utcdate', intype=templateutil.date)
+def utcdate(date):
     '''Date. Returns a UTC-date in this format: "2009/08/18 11:00:13".
     '''
     dateformat = '%Y/%m/%d %H:%M:%S'
-    return dateutil.datestr((dateutil.parsedate(text)[0], 0), dateformat)
+    return dateutil.datestr((date[0], 0), dateformat)
 # date like in svn's $Date
-@templatefilter('svnisodate')
-def svnisodate(text):
+@templatefilter('svnisodate', intype=templateutil.date)
+def svnisodate(date):
     '''Date. Returns a date in this format: "2009-08-18 13:00:13
     +0200 (Tue, 18 Aug 2009)".
     '''
-    return dateutil.datestr(text, '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
+    return dateutil.datestr(date, '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
 # date like in svn's $Id
-@templatefilter('svnutcdate')
-def svnutcdate(text):
+@templatefilter('svnutcdate', intype=templateutil.date)
+def svnutcdate(date):
     '''Date. Returns a UTC-date in this format: "2009-08-18
     11:00:13Z".
     '''
     dateformat = '%Y-%m-%d %H:%M:%SZ'
-    return dateutil.datestr((dateutil.parsedate(text)[0], 0), dateformat)
+    return dateutil.datestr((date[0], 0), dateformat)
 
 # make keyword tools accessible
 kwtools = {'hgcmd': ''}