diff --git a/offlineimap/bundled_imaplib2.py b/offlineimap/bundled_imaplib2.py index c59d0eb..be7a8e9 100644 --- a/offlineimap/bundled_imaplib2.py +++ b/offlineimap/bundled_imaplib2.py @@ -16,7 +16,7 @@ Public functions: Internaldate2Time __all__ = ("IMAP4", "IMAP4_SSL", "IMAP4_stream", "Internaldate2Time", "ParseFlags", "Time2Internaldate", - "Mon2num", "MonthNames", "InternalDate") + "MonthNames", "InternalDate") __version__ = "3.05" __release__ = "3" @@ -58,7 +58,7 @@ __URL__ = "http://imaplib2.sourceforge.net" __license__ = "Python License" import binascii, calendar, errno, os, queue, random, re, select, socket, sys, time, threading, zlib - +import datetime select_module = select @@ -2306,13 +2306,11 @@ class _IdleCont(object): MonthNames = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] -Mon2num = {s.encode():n+1 for n, s in enumerate(MonthNames[1:])} - -InternalDate = re.compile(br'.*INTERNALDATE "' - br'(?P[ 0123][0-9])-(?P[A-Z][a-z][a-z])-(?P[0-9][0-9][0-9][0-9])' - br' (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9])' - br' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])' - br'"') +InternalDate = re.compile(r'.*INTERNALDATE "' + r'(?P[ 0123][0-9])-(?P[A-Z][a-z][a-z])-(?P[0-9][0-9][0-9][0-9])' + r' (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9])' + r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])' + r'"') def Internaldate2Time(resp): @@ -2328,7 +2326,10 @@ def Internaldate2Time(resp): if not mo: return None - mon = Mon2num[mo.group('mon')] + # Get the month number + datetime_object = datetime.datetime.strptime(mo.group('mon'), "%b") + mon = datetime_object.month + zonen = mo.group('zonen') day = int(mo.group('day')) diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py index fff83e8..a57c796 100644 --- a/offlineimap/imaplibutil.py +++ b/offlineimap/imaplibutil.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - +import datetime import os import fcntl import time @@ -30,7 +30,7 @@ import six from offlineimap import OfflineImapError from offlineimap.ui import getglobalui -from offlineimap.virtual_imaplib2 import IMAP4, IMAP4_SSL, InternalDate, Mon2num +from offlineimap.virtual_imaplib2 import IMAP4, IMAP4_SSL, InternalDate class UsefulIMAPMixIn(object): @@ -248,7 +248,10 @@ def Internaldate2epoch(resp): if not mo: return None - mon = Mon2num[mo.group('mon')] + # Get the month number + datetime_object = datetime.datetime.strptime(mo.group('mon'), "%b") + mon = datetime_object.month + zonen = mo.group('zonen') day = int(mo.group('day'))