Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templateutil.py @ 38310: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 |
line wrap: on
line diff
--- a/mercurial/templateutil.py Tue Jun 12 20:43:56 2018 -0400 +++ b/mercurial/templateutil.py Wed Jun 13 21:57:24 2018 +0900 @@ -190,10 +190,11 @@ class date(mappable, wrapped): """Wrapper for date tuple""" - def __init__(self, value): + def __init__(self, value, showfmt='%d %d'): # value may be (float, int), but public interface shouldn't support # floating-point timestamp self._unixtime, self._tzoffset = map(int, value) + self._showfmt = showfmt def contains(self, context, mapping, item): raise error.ParseError(_('date is not iterable')) @@ -211,7 +212,7 @@ raise error.ParseError(_("date is not iterable")) def show(self, context, mapping): - return '%d %d' % (self._unixtime, self._tzoffset) + return self._showfmt % (self._unixtime, self._tzoffset) def tomap(self, context): return {'unixtime': self._unixtime, 'tzoffset': self._tzoffset}