Get the month number

This patch gets the month number using datetime library.

I removed the function Mon2num. The list is not used now, it is removed
too.

I need change the regex in the compile to get the fields. Now is str,
not binary, so I remored the 'b'.
This commit is contained in:
Rodolfo García Peñas (kix)
2020-08-28 20:05:52 +02:00
parent e61e77cf40
commit 36bfbdf7d6
2 changed files with 17 additions and 13 deletions

View File

@ -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'))