Mercurial > cpython-lru_cache-weakref
diff Lib/email/_parseaddr.py @ 64274:87bdf53ff4bb
#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.
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Wed, 25 Aug 2010 00:45:55 +0000 |
| parents | d5f3c2f416f2 |
| children | ef5c57217b20 |
line wrap: on
line diff
--- a/Lib/email/_parseaddr.py Wed Aug 25 00:20:27 2010 +0000 +++ b/Lib/email/_parseaddr.py Wed Aug 25 00:45:55 2010 +0000 @@ -107,6 +107,18 @@ tss = int(tss) except ValueError: return None + # Check for a yy specified in two-digit format, then convert it to the + # appropriate four-digit format, according to the POSIX standard. RFC 822 + # calls for a two-digit yy, but RFC 2822 (which obsoletes RFC 822) + # mandates a 4-digit yy. For more information, see the documentation for + # the time module. + if yy < 100: + # The year is between 1969 and 1999 (inclusive). + if yy > 68: + yy += 1900 + # The year is between 2000 and 2068 (inclusive). + else: + yy += 2000 tzoffset = None tz = tz.upper() if tz in _timezones:
