--- Lib/imaplib.py 2011-01-16 15:42:08.320437051 -0700 +++ Lib/imaplib.py.new 2011-01-16 12:45:13.628398871 -0700 @@ -22,7 +22,7 @@ __version__ = "2.58" -import binascii, errno, random, re, socket, subprocess, sys, time +import binascii, errno, random, re, socket, subprocess, sys, time, calendar try: import ssl @@ -1308,8 +1308,8 @@ -Mon2num = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, - 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12} +Mon2num = {b'Jan': 1, b'Feb': 2, b'Mar': 3, b'Apr': 4, b'May': 5, b'Jun': 6, + b'Jul': 7, b'Aug': 8, b'Sep': 9, b'Oct': 10, b'Nov': 11, b'Dec': 12} def Internaldate2tuple(resp): """Convert IMAP4 INTERNALDATE to UT. @@ -1335,23 +1335,13 @@ # INTERNALDATE timezone must be subtracted to get UT zone = (zoneh*60 + zonem)*60 - if zonen == '-': + if zonen == b'-': zone = -zone tt = (year, mon, day, hour, min, sec, -1, -1, -1) + utc = calendar.timegm(tt) - zone - utc = time.mktime(tt) - - # Following is necessary because the time module has no 'mkgmtime'. - # 'mktime' assumes arg in local timezone, so adds timezone/altzone. - - lt = time.localtime(utc) - if time.daylight and lt[-1]: - zone = zone + time.altzone - else: - zone = zone + time.timezone - - return time.localtime(utc - zone) + return time.gmtime(utc)