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

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 3, 2016, 1:04 p.m.
Message ID <2e03c852e430516e4bc8.1470229467@mimosa>
Download mbox | patch
Permalink /patch/16054/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 3, 2016, 1:04 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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

Patch

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)