Date format incompatibility

Edward Z. Yang ezyang at MIT.EDU
Wed Jun 15 12:56:57 BST 2011


Today, I discovered that offlineimap had mysteriously stopped being
able to sync emails.  I tracked down the error to the following query
being issued:

    SINCE 01-June-2011

It turns out my IMAP mailserver doesn't like June and only accepts Jun.

    def cachemessagelist(self):
        # ...
            if (maxage != -1) | (maxsize != -1):
                try:
                    search_condition = "(";

                    if(maxage != -1):
                        #find out what the oldest message is that we should look at
                        oldest_time_struct = time.gmtime(time.time() - (60*60*24*maxage))

                        #format this manually - otherwise locales could cause problems
                        monthnames_standard = ["Jan", "Feb", "Mar", "Apr", "May", \
                            "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"]

                        our_monthname = monthnames_standard[oldest_time_struct[1]-1]
                        daystr = "%(day)02d" % {'day' : oldest_time_struct[2]}
                        date_search_str = "SINCE " + daystr + "-" + our_monthname \
                            + "-" + str(oldest_time_struct[0])

                        search_condition += date_search_str

It would be interesting to know if other people possibly had this problem.

Cheers,
Edward




More information about the OfflineIMAP-project mailing list