Mercurial > public > mercurial-scm > hg
comparison mercurial/formatter.py @ 29678:2f3f18ad55a2
formatter: add function to convert date tuple to appropriate format
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 31 Jul 2016 17:07:29 +0900 |
parents | c3a9cd78b151 |
children | 4891f3b93182 |
comparison
equal
deleted
inserted
replaced
29677:69890b5dd32b | 29678:2f3f18ad55a2 |
---|---|
44 def startitem(self): | 44 def startitem(self): |
45 '''begin an item in the format list''' | 45 '''begin an item in the format list''' |
46 if self._item is not None: | 46 if self._item is not None: |
47 self._showitem() | 47 self._showitem() |
48 self._item = {} | 48 self._item = {} |
49 @staticmethod | |
50 def formatdate(date, fmt='%a %b %d %H:%M:%S %Y %1%2'): | |
51 '''convert date tuple to appropriate format''' | |
52 return date | |
49 @staticmethod | 53 @staticmethod |
50 def formatlist(data, name, fmt='%s', sep=' '): | 54 def formatlist(data, name, fmt='%s', sep=' '): |
51 '''convert iterable to appropriate list format''' | 55 '''convert iterable to appropriate list format''' |
52 return list(data) | 56 return list(data) |
53 def data(self, **data): | 57 def data(self, **data): |
82 def __nonzero__(self): | 86 def __nonzero__(self): |
83 return False | 87 return False |
84 def startitem(self): | 88 def startitem(self): |
85 pass | 89 pass |
86 @staticmethod | 90 @staticmethod |
91 def formatdate(date, fmt='%a %b %d %H:%M:%S %Y %1%2'): | |
92 '''stringify date tuple in the given format''' | |
93 return util.datestr(date, fmt) | |
94 @staticmethod | |
87 def formatlist(data, name, fmt='%s', sep=' '): | 95 def formatlist(data, name, fmt='%s', sep=' '): |
88 '''stringify iterable separated by sep''' | 96 '''stringify iterable separated by sep''' |
89 return sep.join(fmt % e for e in data) | 97 return sep.join(fmt % e for e in data) |
90 def data(self, **data): | 98 def data(self, **data): |
91 pass | 99 pass |