]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
FixedOffsetTimezone: fix display of negative offsets 219/head
authorAlex Willmer <alex@moreati.org.uk>
Thu, 10 Sep 2015 19:25:45 +0000 (20:25 +0100)
committerAlex Willmer <alex@moreati.org.uk>
Thu, 10 Sep 2015 19:25:45 +0000 (20:25 +0100)
babel/util.py
tests/test_util.py

index c366214189682ebf36648f7b36ce8ee0af9cf865..495e9431210fbd6752f755dd2b9bcd32f18aaee3 100644 (file)
@@ -261,7 +261,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):
index 6ec73dc52d0ba1011c3dcfa11cc7cdfda1b34da5..bb2bfdb4ba742d60fdb99a1dd35eeeab8fcd3ce5 100644 (file)
@@ -11,6 +11,7 @@
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://babel.edgewall.org/log/.
 
+import unittest
 
 from babel import util
 
@@ -39,3 +40,15 @@ def test_odict_pop():
         assert False
     except KeyError:
         assert True
+
+
+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)
+