##// END OF EJS Templates
date: allow %z in format (issue4040)
Matt Mackall -
r19989:c38c3fdc default
parent child Browse files
Show More
@@ -1025,9 +1025,10 b" def datestr(date=None, format='%a %b %d "
1025 if t < 0:
1025 if t < 0:
1026 t = 0 # time.gmtime(lt) fails on Windows for lt < -43200
1026 t = 0 # time.gmtime(lt) fails on Windows for lt < -43200
1027 tz = 0
1027 tz = 0
1028 if "%1" in format or "%2" in format:
1028 if "%1" in format or "%2" in format or "%z" in format:
1029 sign = (tz > 0) and "-" or "+"
1029 sign = (tz > 0) and "-" or "+"
1030 minutes = abs(tz) // 60
1030 minutes = abs(tz) // 60
1031 format = format.replace("%z", "%1%2")
1031 format = format.replace("%1", "%c%02d" % (sign, minutes // 60))
1032 format = format.replace("%1", "%c%02d" % (sign, minutes // 60))
1032 format = format.replace("%2", "%02d" % (minutes % 60))
1033 format = format.replace("%2", "%02d" % (minutes % 60))
1033 try:
1034 try:
@@ -1445,7 +1445,7 b' latesttag:'
1445 $ hg ci -m h2e -d '4 0'
1445 $ hg ci -m h2e -d '4 0'
1446
1446
1447 $ hg merge -q
1447 $ hg merge -q
1448 $ hg ci -m merge -d '5 0'
1448 $ hg ci -m merge -d '5 -3600'
1449
1449
1450 No tag set:
1450 No tag set:
1451
1451
@@ -1533,7 +1533,7 b' if it is a relative path'
1533 > EOF
1533 > EOF
1534
1534
1535 $ hg -R latesttag tip
1535 $ hg -R latesttag tip
1536 test 10:dee8f28249af
1536 test 10:9b4a630e5f5f
1537
1537
1538 Test recursive showlist template (issue1989):
1538 Test recursive showlist template (issue1989):
1539
1539
@@ -1586,3 +1586,18 b' Test the strip function with chars speci'
1586 h1c
1586 h1c
1587 b
1587 b
1588 a
1588 a
1589
1590 Test date format:
1591
1592 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
1593 date: 70 01 01 10 +0000
1594 date: 70 01 01 09 +0000
1595 date: 70 01 01 08 +0000
1596 date: 70 01 01 07 +0000
1597 date: 70 01 01 06 +0000
1598 date: 70 01 01 05 +0100
1599 date: 70 01 01 04 +0000
1600 date: 70 01 01 03 +0000
1601 date: 70 01 01 02 +0000
1602 date: 70 01 01 01 +0000
1603 date: 70 01 01 00 +0000
General Comments 0
You need to be logged in to leave comments. Login now