Simplify constructing the SEARCH date

We can use Imaplib's monthnames and shorten the construction of the date
by using them rather than hardcoding them again.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-09-07 18:21:44 +02:00 committed by Nicolas Sebrecht
parent 1b99c019e5
commit 135f8c45cf

View File

@ -24,6 +24,7 @@ import time
from sys import exc_info
from Base import BaseFolder
from offlineimap import imaputil, imaplibutil, OfflineImapError
from offlineimap.imaplib2 import MonthNames
try: # python 2.6 has set() built in
set
except NameError:
@ -132,15 +133,9 @@ class IMAPFolder(BaseFolder):
if(maxage != -1):
#find out what the oldest message is that we should look at
oldest_struct = time.gmtime(time.time() - (60*60*24*maxage))
#format months manually - otherwise locales cause problems
monthnames = ["Jan", "Feb", "Mar", "Apr", "May", \
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
month = monthnames[oldest_struct[1]-1]
daystr = "%(day)02d" % {'day' : oldest_struct[2]}
search_cond += "SINCE %s-%s-%s" % (daystr, month,
search_cond += "SINCE %02d-%s-%d" % (
oldest_struct[2],
MonthNames[oldest_struct[1]],
oldest_struct[0])
if(maxsize != -1):