summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Willmer <alex@moreati.org.uk>2015-09-10 20:25:45 +0100
committerAlex Willmer <alex@moreati.org.uk>2015-09-10 20:35:52 +0100
commitfb65159add3eb40be9ab5c9989c3ffe09e333106 (patch)
tree57ca16835575fe5aa0dedc53b7d7ad0213dca522
parentaa5b28d3c59c2fa811e929cf8158b4f942faf86e (diff)
downloadbabel-fb65159add3eb40be9ab5c9989c3ffe09e333106.tar.gz
Backport: FixedOffsetTimezone: fix display of negative offsets
-rw-r--r--babel/util.py2
-rw-r--r--tests/test_util.py12
2 files changed, 13 insertions, 1 deletions
diff --git a/babel/util.py b/babel/util.py
index a65fce3..27377f3 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 321014c..c01c922 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)
+