util: Fix timezone offset

We need to negate the value: the values are in seconds west of UTC, but
ISO 8601 wants the offset to be negative for times behind UTC (i.e. to
the west).

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-09-12 09:36:45 +02:00
parent d34c0a2777
commit 9dbf231080
2 changed files with 8 additions and 5 deletions

View file

@ -597,18 +597,18 @@ class TestTZOffset(unittest.TestCase):
@mock.patch('time.timezone', new=3600)
@mock.patch('time.localtime', new=lambda: mock.Mock(tm_isdst=0))
def test_zone_without_dst(self):
self.assertEqual(util.get_tz_offset(), "+01:00")
self.assertEqual(util.get_tz_offset(), "-01:00")
@mock.patch('time.daylight', new=True)
@mock.patch('time.altzone', new=7200)
@mock.patch('time.timezone', new=3600)
@mock.patch('time.localtime', new=lambda: mock.Mock(tm_isdst=0))
def test_with_active_dst(self):
self.assertEqual(util.get_tz_offset(), "+01:00")
self.assertEqual(util.get_tz_offset(), "-01:00")
@mock.patch('time.daylight', new=True)
@mock.patch('time.altzone', new=9000)
@mock.patch('time.timezone', new=3600)
@mock.patch('time.altzone', new=-9000)
@mock.patch('time.timezone', new=-3600)
@mock.patch('time.localtime', new=lambda: mock.Mock(tm_isdst=1))
def test_with_inactive_dst(self):
self.assertEqual(util.get_tz_offset(), "+02:30")