diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-04-04 02:05:37 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-04-04 02:05:37 +0200 |
commit | 2e4f1f19bc2ba3b8e691e2387bff342f0f1d98b0 (patch) | |
tree | 3fbaabc79559662146fc66a8afc7406de79c2612 /fastimport | |
parent | e027fb49874db5d389fa2fd15706dcb5820db3f3 (diff) | |
download | python-fastimport-git-2e4f1f19bc2ba3b8e691e2387bff342f0f1d98b0.tar.gz |
Cope with invalid timezones like +51800 a little bit better.
Diffstat (limited to 'fastimport')
-rw-r--r-- | fastimport/dates.py | 6 | ||||
-rw-r--r-- | fastimport/tests/test_dates.py | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/fastimport/dates.py b/fastimport/dates.py index c0cf400..65223f8 100644 --- a/fastimport/dates.py +++ b/fastimport/dates.py @@ -48,11 +48,11 @@ def parse_tz(tz): :return: the timezone offset in seconds. """ # from git_repository.py in bzr-git - if len(tz) != 5: + if tz[0] not in ('+', '-'): raise ValueError(tz) sign = {'+': +1, '-': -1}[tz[0]] - hours = int(tz[1:3]) - minutes = int(tz[3:]) + hours = int(tz[1:-2]) + minutes = int(tz[-2:]) return sign * 60 * (60 * hours + minutes) diff --git a/fastimport/tests/test_dates.py b/fastimport/tests/test_dates.py index 109318c..aae8b78 100644 --- a/fastimport/tests/test_dates.py +++ b/fastimport/tests/test_dates.py @@ -29,3 +29,6 @@ class ParseTzTests(TestCase): def test_parse_tz_cet(self): self.assertEquals(3600, dates.parse_tz("+0100")) + + def test_parse_tz_odd(self): + self.assertEquals(1864800, dates.parse_tz("+51800")) |