comparison mercurial/templateutil.py @ 38299:88e7105b5cd9

templater: restore the original string format of {date} Unfortunately, python-hglib relies on that. I could fix python-hglib, but there would be other tools that take a decimal separator as the separator of unixtime and tzoffset. The showfmt is set per instance since new code uses '%d %d' format by default.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 13 Jun 2018 21:57:24 +0900
parents f9c426385853
children b6294c113794
comparison
equal deleted inserted replaced
38298:af0e88e64ede 38299:88e7105b5cd9
188 return self._value 188 return self._value
189 189
190 class date(mappable, wrapped): 190 class date(mappable, wrapped):
191 """Wrapper for date tuple""" 191 """Wrapper for date tuple"""
192 192
193 def __init__(self, value): 193 def __init__(self, value, showfmt='%d %d'):
194 # value may be (float, int), but public interface shouldn't support 194 # value may be (float, int), but public interface shouldn't support
195 # floating-point timestamp 195 # floating-point timestamp
196 self._unixtime, self._tzoffset = map(int, value) 196 self._unixtime, self._tzoffset = map(int, value)
197 self._showfmt = showfmt
197 198
198 def contains(self, context, mapping, item): 199 def contains(self, context, mapping, item):
199 raise error.ParseError(_('date is not iterable')) 200 raise error.ParseError(_('date is not iterable'))
200 201
201 def getmember(self, context, mapping, key): 202 def getmember(self, context, mapping, key):
209 210
210 def join(self, context, mapping, sep): 211 def join(self, context, mapping, sep):
211 raise error.ParseError(_("date is not iterable")) 212 raise error.ParseError(_("date is not iterable"))
212 213
213 def show(self, context, mapping): 214 def show(self, context, mapping):
214 return '%d %d' % (self._unixtime, self._tzoffset) 215 return self._showfmt % (self._unixtime, self._tzoffset)
215 216
216 def tomap(self, context): 217 def tomap(self, context):
217 return {'unixtime': self._unixtime, 'tzoffset': self._tzoffset} 218 return {'unixtime': self._unixtime, 'tzoffset': self._tzoffset}
218 219
219 def tobool(self, context, mapping): 220 def tobool(self, context, mapping):