From 135f8c45cfb24cc202d2589bfb13fdbaedbfd5f1 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Wed, 7 Sep 2011 18:21:44 +0200 Subject: [PATCH] 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 Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index cc04262..339f271 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -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,16 +133,10 @@ 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, - oldest_struct[0]) + search_cond += "SINCE %02d-%s-%d" % ( + oldest_struct[2], + MonthNames[oldest_struct[1]], + oldest_struct[0]) if(maxsize != -1): if(maxage != -1): # There are two conditions, add space