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:
parent
1b99c019e5
commit
135f8c45cf
@ -24,6 +24,7 @@ import time
|
|||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
from Base import BaseFolder
|
from Base import BaseFolder
|
||||||
from offlineimap import imaputil, imaplibutil, OfflineImapError
|
from offlineimap import imaputil, imaplibutil, OfflineImapError
|
||||||
|
from offlineimap.imaplib2 import MonthNames
|
||||||
try: # python 2.6 has set() built in
|
try: # python 2.6 has set() built in
|
||||||
set
|
set
|
||||||
except NameError:
|
except NameError:
|
||||||
@ -132,15 +133,9 @@ class IMAPFolder(BaseFolder):
|
|||||||
if(maxage != -1):
|
if(maxage != -1):
|
||||||
#find out what the oldest message is that we should look at
|
#find out what the oldest message is that we should look at
|
||||||
oldest_struct = time.gmtime(time.time() - (60*60*24*maxage))
|
oldest_struct = time.gmtime(time.time() - (60*60*24*maxage))
|
||||||
|
search_cond += "SINCE %02d-%s-%d" % (
|
||||||
#format months manually - otherwise locales cause problems
|
oldest_struct[2],
|
||||||
monthnames = ["Jan", "Feb", "Mar", "Apr", "May", \
|
MonthNames[oldest_struct[1]],
|
||||||
"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,
|
|
||||||
oldest_struct[0])
|
oldest_struct[0])
|
||||||
|
|
||||||
if(maxsize != -1):
|
if(maxsize != -1):
|
||||||
|
Loading…
Reference in New Issue
Block a user