From: Alex Willmer Date: Thu, 10 Sep 2015 19:25:45 +0000 (+0100) Subject: Backport: FixedOffsetTimezone: fix display of negative offsets X-Git-Tag: 2.1.1~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F220%2Fhead;p=thirdparty%2Fbabel.git Backport: FixedOffsetTimezone: fix display of negative offsets --- diff --git a/babel/util.py b/babel/util.py index a65fce36..27377f3d 100644 --- a/babel/util.py +++ b/babel/util.py @@ -255,7 +255,7 @@ class FixedOffsetTimezone(tzinfo): def __init__(self, offset, name=None): self._offset = timedelta(minutes=offset) if name is None: - name = 'Etc/GMT+%d' % offset + name = 'Etc/GMT%+d' % offset self.zone = name def __str__(self): diff --git a/tests/test_util.py b/tests/test_util.py index 321014c9..c01c9226 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -28,3 +28,15 @@ def test_pathmatch(): assert not util.pathmatch('**.py', 'templates/index.html') assert util.pathmatch('**/templates/*.html', 'templates/index.html') assert not util.pathmatch('**/templates/*.html', 'templates/foo/bar.html') + + +class FixedOffsetTimezoneTestCase(unittest.TestCase): + def test_zone_negative_offset(self): + self.assertEqual('Etc/GMT-60', util.FixedOffsetTimezone(-60).zone) + + def test_zone_zero_offset(self): + self.assertEqual('Etc/GMT+0', util.FixedOffsetTimezone(0).zone) + + def test_zone_positive_offset(self): + self.assertEqual('Etc/GMT+330', util.FixedOffsetTimezone(330).zone) +