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

Skip to content

Commit 602426e

Browse files
committed
parsedate_tz(): Minor cleanup.
Port from Python 2.3/email 2.5: Add a test for the tm_yday field is 1 in the return of parsedate().
1 parent 5a49fae commit 602426e

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

Lib/email/_parseaddr.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2002-2004 Python Software Foundation
1+
# Copyright (C) 2002-2006 Python Software Foundation
22
33

44
"""Email address parsing code.
@@ -117,8 +117,7 @@ def parsedate_tz(data):
117117
else:
118118
tzsign = 1
119119
tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60)
120-
tuple = (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset)
121-
return tuple
120+
return yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset
122121

123122

124123
def parsedate(data):

Lib/email/test/test_email.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,15 @@ def test_parsedate_compact_no_dayofweek(self):
21042104
eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
21052105
(2003, 2, 5, 13, 47, 26, 0, 1, 0, -28800))
21062106

2107+
def test_parsedate_acceptable_to_time_functions(self):
2108+
eq = self.assertEqual
2109+
timetup = Utils.parsedate('5 Feb 2003 13:47:26 -0800')
2110+
eq(int(time.mktime(timetup)), 1044470846)
2111+
eq(int(time.strftime('%Y', timetup)), 2003)
2112+
timetup = Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800')
2113+
eq(int(time.mktime(timetup[:9])), 1044470846)
2114+
eq(int(time.strftime('%Y', timetup[:9])), 2003)
2115+
21072116
def test_parseaddr_empty(self):
21082117
self.assertEqual(Utils.parseaddr('<>'), ('', ''))
21092118
self.assertEqual(Utils.formataddr(Utils.parseaddr('<>')), '')

0 commit comments

Comments
 (0)