]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Backport: FixedOffsetTimezone: fix display of negative offsets 220/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:35:52 +0000 (20:35 +0100)
babel/util.py
tests/test_util.py

index a65fce36e3169d772a29c0951db49ede48564530..27377f3d2c3b12a051194c5ef60eed4612e2a999 100644 (file)
@@ -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):
index 321014c90bd28465f2984784c58bddecd6878519..c01c922663c2b0f3f10a9474e596d5a06dfea25d 100644 (file)
@@ -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)
+