Mercurial > hg-stable
changeset 27066:6f1f8e88f036
util.datestr: use divmod()
We were computing the quotient and remainder of a division operation
separately. The built-in divmod() function allows us to do this with
a single function call. Do that.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 14 Nov 2015 17:30:10 -0800 |
parents | 93bcc73df8d5 |
children | 19b52cde2b84 |
files | mercurial/util.py |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Sat Nov 14 17:44:01 2015 -0800 +++ b/mercurial/util.py Sat Nov 14 17:30:10 2015 -0800 @@ -1367,9 +1367,10 @@ if "%1" in format or "%2" in format or "%z" in format: sign = (tz > 0) and "-" or "+" minutes = abs(tz) // 60 + q, r = divmod(minutes, 60) format = format.replace("%z", "%1%2") - format = format.replace("%1", "%c%02d" % (sign, minutes // 60)) - format = format.replace("%2", "%02d" % (minutes % 60)) + format = format.replace("%1", "%c%02d" % (sign, q)) + format = format.replace("%2", "%02d" % r) try: t = time.gmtime(float(t) - tz) except ValueError: