summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-04-04 02:05:37 +0200
committerJelmer Vernooij <jelmer@samba.org>2012-04-04 02:05:37 +0200
commit55170a74a2999fa5bcdd6099523831371c3be204 (patch)
tree3fbaabc79559662146fc66a8afc7406de79c2612
parentf4d52ab7bf5eae5f12f8dee300543bc827ed473b (diff)
downloadpython-fastimport-55170a74a2999fa5bcdd6099523831371c3be204.tar.gz
Cope with invalid timezones like +51800 a little bit better.
-rw-r--r--NEWS3
-rw-r--r--fastimport/dates.py6
-rw-r--r--fastimport/tests/test_dates.py3
3 files changed, 9 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 552926d..969ef75 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@
* Remove reftracker and idmapfile, which are bzr-specific.
(Jelmer Vernooij, #693507)
+ * Cope with invalid timezones like +61800 a little bit better.
+ (Jelmer Vernooij, #959154)
+
0.9.1 2012-02-28
* Update FSF address in headers. (Dan Callaghan, #868800)
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"))