Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 31449:756175623f2e
py3: call strftime() with native str type
Since strftime() may contain non-ascii character if locale set, we use
strfrom/tolocal().
Now "hg tip" works.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 13 Mar 2017 09:19:07 -0700 |
parents | 6419cd243017 |
children | 53865692a354 |
comparison
equal
deleted
inserted
replaced
31448:6419cd243017 | 31449:756175623f2e |
---|---|
1790 d = -0x80000000 | 1790 d = -0x80000000 |
1791 # Never use time.gmtime() and datetime.datetime.fromtimestamp() | 1791 # Never use time.gmtime() and datetime.datetime.fromtimestamp() |
1792 # because they use the gmtime() system call which is buggy on Windows | 1792 # because they use the gmtime() system call which is buggy on Windows |
1793 # for negative values. | 1793 # for negative values. |
1794 t = datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=d) | 1794 t = datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=d) |
1795 s = t.strftime(format) | 1795 s = encoding.strtolocal(t.strftime(encoding.strfromlocal(format))) |
1796 return s | 1796 return s |
1797 | 1797 |
1798 def shortdate(date=None): | 1798 def shortdate(date=None): |
1799 """turn (timestamp, tzoff) tuple into iso 8631 date.""" | 1799 """turn (timestamp, tzoff) tuple into iso 8631 date.""" |
1800 return datestr(date, format='%Y-%m-%d') | 1800 return datestr(date, format='%Y-%m-%d') |