Mercurial > hg-stable
changeset 29637:46b2ccce7fde stable
date: parse ISO-style Z and +hh:mm timezone specs
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 27 Jul 2016 15:20:34 -0500 |
parents | 84ef4517de03 |
children | 491ee264b9f6 |
files | mercurial/util.py |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Wed Jul 27 15:14:19 2016 -0500 +++ b/mercurial/util.py Wed Jul 27 15:20:34 2016 -0500 @@ -1760,6 +1760,18 @@ minutes = int(s[-2:]) return -sign * (hours * 60 + minutes) * 60, s[:-5].rstrip() + # ISO8601 trailing Z + if s.endswith("Z") and s[-2:-1].isdigit(): + return 0, s[:-1] + + # ISO8601-style [+-]hh:mm + if (len(s) >= 6 and s[-6] in "+-" and s[-3] == ":" and + s[-5:-3].isdigit() and s[-2:].isdigit()): + sign = (s[-6] == "+") and 1 or -1 + hours = int(s[-5:-3]) + minutes = int(s[-2:]) + return -sign * (hours * 60 + minutes) * 60, s[:-6] + return None, s def strdate(string, format, defaults=[]):