Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4586d2c

Browse files
committed
test_formatdate(): Remove the unnecessary ldate calculation.
test_formatdate_zoneoffsets() => test_formatdate_localtime(): Do the sign corrected calculation of the zone offset.
1 parent e5739a6 commit 4586d2c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Lib/test/test_email.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,14 +932,17 @@ def test_formatdate(self):
932932
else:
933933
matchdate = "I don't understand your epoch"
934934
gdate = Utils.formatdate(now)
935-
ldate = Utils.formatdate(now, localtime=1)
936935
self.assertEqual(gdate, matchdate)
937936

938-
def test_formatdate_zoneoffsets(self):
937+
def test_formatdate_localtime(self):
939938
now = 1005327232.109884
940939
ldate = Utils.formatdate(now, localtime=1)
941940
zone = ldate.split()[5]
942-
offset = int(zone[:3]) * -3600 + int(zone[-2:]) * -60
941+
offset = int(zone[1:3]) * 3600 + int(zone[-2:]) * 60
942+
# Remember offset is in seconds west of UTC, but the timezone is in
943+
# minutes east of UTC, so the signs differ.
944+
if zone[0] == '+':
945+
offset = -offset
943946
if time.daylight and time.localtime(now)[-1]:
944947
toff = time.altzone
945948
else:

0 commit comments

Comments
 (0)