mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
#1194222: make parsedate always return RFC2822 four character years.
Two character years are now converted to four character years using the Posix standard rule (<68 == 2000, >=68==1900). This makes the parsed date RFC2822 compliant even if the input is not. Patch and test by Jeffrey Finkelstein.
This commit is contained in:
parent
1970b62aee
commit
219d1c8ae3
4 changed files with 29 additions and 0 deletions
|
@ -2234,6 +2234,19 @@ class TestMiscellaneous(TestEmailBase):
|
|||
eq(time.localtime(t)[:6], timetup[:6])
|
||||
eq(int(time.strftime('%Y', timetup[:9])), 2003)
|
||||
|
||||
def test_parsedate_y2k(self):
|
||||
"""Test for parsing a date with a two-digit year.
|
||||
|
||||
Parsing a date with a two-digit year should return the correct
|
||||
four-digit year. RFC822 allows two-digit years, but RFC2822 (which
|
||||
obsoletes RFC822) requires four-digit years.
|
||||
|
||||
"""
|
||||
self.assertEqual(utils.parsedate_tz('25 Feb 03 13:47:26 -0800'),
|
||||
utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'))
|
||||
self.assertEqual(utils.parsedate_tz('25 Feb 71 13:47:26 -0800'),
|
||||
utils.parsedate_tz('25 Feb 1971 13:47:26 -0800'))
|
||||
|
||||
def test_parseaddr_empty(self):
|
||||
self.assertEqual(utils.parseaddr('<>'), ('', ''))
|
||||
self.assertEqual(utils.formataddr(utils.parseaddr('<>')), '')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue