[PATCH 4 of 5] formatter: add function to convert date tuple to appropriate format

Yuya Nishihara yuya at tcha.org
Wed Aug 3 09:04:27 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1469952449 -32400
#      Sun Jul 31 17:07:29 2016 +0900
# Node ID 2e03c852e430516e4bc881cb0b70a6ec922cf5bf
# Parent  3afa71f0be6185b22ff586718bbe0897e0eeb56e
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)


More information about the Mercurial-devel mailing list