# HG changeset patch # User Yuya Nishihara # Date 2016-07-31 08:07:29 # Node ID 2f3f18ad55a2b249bc0d1b3b49f0ed0929f7b729 # Parent 69890b5dd32b760bb36cb8d9392a8ba6cf75a575 formatter: add function to convert date tuple to appropriate format diff --git a/mercurial/formatter.py b/mercurial/formatter.py --- a/mercurial/formatter.py +++ b/mercurial/formatter.py @@ -47,6 +47,10 @@ class baseformatter(object): self._showitem() self._item = {} @staticmethod + def formatdate(date, fmt='%a %b %d %H:%M:%S %Y %1%2'): + '''convert date tuple to appropriate format''' + return date + @staticmethod def formatlist(data, name, fmt='%s', sep=' '): '''convert iterable to appropriate list format''' return list(data) @@ -84,6 +88,10 @@ class plainformatter(baseformatter): def startitem(self): pass @staticmethod + def formatdate(date, fmt='%a %b %d %H:%M:%S %Y %1%2'): + '''stringify date tuple in the given format''' + return util.datestr(date, fmt) + @staticmethod def formatlist(data, name, fmt='%s', sep=' '): '''stringify iterable separated by sep''' return sep.join(fmt % e for e in data)