Mercurial > hg
changeset 19989:c38c3fdc8b93
date: allow %z in format (issue4040)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 07 Nov 2013 15:24:23 -0600 |
parents | 8dc6f855f43d |
children | ce5d711475a3 |
files | mercurial/util.py tests/test-command-template.t |
diffstat | 2 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Wed Nov 06 16:36:07 2013 -0600 +++ b/mercurial/util.py Thu Nov 07 15:24:23 2013 -0600 @@ -1025,9 +1025,10 @@ if t < 0: t = 0 # time.gmtime(lt) fails on Windows for lt < -43200 tz = 0 - if "%1" in format or "%2" in format: + if "%1" in format or "%2" in format or "%z" in format: sign = (tz > 0) and "-" or "+" minutes = abs(tz) // 60 + format = format.replace("%z", "%1%2") format = format.replace("%1", "%c%02d" % (sign, minutes // 60)) format = format.replace("%2", "%02d" % (minutes % 60)) try:
--- a/tests/test-command-template.t Wed Nov 06 16:36:07 2013 -0600 +++ b/tests/test-command-template.t Thu Nov 07 15:24:23 2013 -0600 @@ -1445,7 +1445,7 @@ $ hg ci -m h2e -d '4 0' $ hg merge -q - $ hg ci -m merge -d '5 0' + $ hg ci -m merge -d '5 -3600' No tag set: @@ -1533,7 +1533,7 @@ > EOF $ hg -R latesttag tip - test 10:dee8f28249af + test 10:9b4a630e5f5f Test recursive showlist template (issue1989): @@ -1586,3 +1586,18 @@ h1c b a + +Test date format: + + $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n' + date: 70 01 01 10 +0000 + date: 70 01 01 09 +0000 + date: 70 01 01 08 +0000 + date: 70 01 01 07 +0000 + date: 70 01 01 06 +0000 + date: 70 01 01 05 +0100 + date: 70 01 01 04 +0000 + date: 70 01 01 03 +0000 + date: 70 01 01 02 +0000 + date: 70 01 01 01 +0000 + date: 70 01 01 00 +0000