From 55170a74a2999fa5bcdd6099523831371c3be204 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 4 Apr 2012 02:05:37 +0200 Subject: Cope with invalid timezones like +51800 a little bit better. --- NEWS | 3 +++ fastimport/dates.py | 6 +++--- fastimport/tests/test_dates.py | 3 +++ 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")) -- cgit v1.2.1