Commit 4586d2c9 authored by Barry Warsaw's avatar Barry Warsaw

test_formatdate(): Remove the unnecessary ldate calculation.

test_formatdate_zoneoffsets() => test_formatdate_localtime(): Do the
sign corrected calculation of the zone offset.
parent e5739a69
...@@ -932,14 +932,17 @@ class TestMiscellaneous(unittest.TestCase): ...@@ -932,14 +932,17 @@ class TestMiscellaneous(unittest.TestCase):
else: else:
matchdate = "I don't understand your epoch" matchdate = "I don't understand your epoch"
gdate = Utils.formatdate(now) gdate = Utils.formatdate(now)
ldate = Utils.formatdate(now, localtime=1)
self.assertEqual(gdate, matchdate) self.assertEqual(gdate, matchdate)
def test_formatdate_zoneoffsets(self): def test_formatdate_localtime(self):
now = 1005327232.109884 now = 1005327232.109884
ldate = Utils.formatdate(now, localtime=1) ldate = Utils.formatdate(now, localtime=1)
zone = ldate.split()[5] zone = ldate.split()[5]
offset = int(zone[:3]) * -3600 + int(zone[-2:]) * -60 offset = int(zone[1:3]) * 3600 + int(zone[-2:]) * 60
# Remember offset is in seconds west of UTC, but the timezone is in
# minutes east of UTC, so the signs differ.
if zone[0] == '+':
offset = -offset
if time.daylight and time.localtime(now)[-1]: if time.daylight and time.localtime(now)[-1]:
toff = time.altzone toff = time.altzone
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment