From 602426e3cf4a65fe37fbe17a3e3a106d0a998811 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Fri, 3 Feb 2006 04:44:52 +0000 Subject: [PATCH] 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(). --- Lib/email/_parseaddr.py | 5 ++--- Lib/email/test/test_email.py | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index f6efcd5c1ea..7d759efbcff 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2004 Python Software Foundation +# Copyright (C) 2002-2006 Python Software Foundation # Contact: email-sig@python.org """Email address parsing code. @@ -117,8 +117,7 @@ def parsedate_tz(data): else: tzsign = 1 tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60) - tuple = (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset) - return tuple + return yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset def parsedate(data): diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index c22603df7db..a68ceba49c3 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -2104,6 +2104,15 @@ class TestMiscellaneous(TestEmailBase): eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'), (2003, 2, 5, 13, 47, 26, 0, 1, 0, -28800)) + def test_parsedate_acceptable_to_time_functions(self): + eq = self.assertEqual + timetup = Utils.parsedate('5 Feb 2003 13:47:26 -0800') + eq(int(time.mktime(timetup)), 1044470846) + eq(int(time.strftime('%Y', timetup)), 2003) + timetup = Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800') + eq(int(time.mktime(timetup[:9])), 1044470846) + eq(int(time.strftime('%Y', timetup[:9])), 2003) + def test_parseaddr_empty(self): self.assertEqual(Utils.parseaddr('<>'), ('', '')) self.assertEqual(Utils.formataddr(Utils.parseaddr('<>')), '')