'Return maxage.
maxage is allowed to be either an integer or a date of the form
YYYY-mm-dd. This returns a time_struct.'

def getmaxage(self):

    maxagestr = self.config.getdefault(('Account    %s' % self.accountname), 'maxage', None)
    if (maxagestr is None):
        return None
    try:
        maxage = int(maxagestr)
        if (maxage < 1):
            raise OfflineImapError(('invalid    maxage    value    %d' % maxage), OfflineImapError.ERROR.MESSAGE)
        return time.gmtime((time.time() - (((60 * 60) * 24) * maxage)))
    except ValueError:
        pass
    try:
        date = time.strptime(maxagestr, '%Y-%m-%d')
        if (date[0] < 1900):
            raise OfflineImapError(('maxage    led    to    year    %d.    Abort    syncing.' % date[0]), OfflineImapError.ERROR.MESSAGE)
        if ((time.mktime(date) - time.mktime(time.localtime())) > 0):
            raise OfflineImapError(('maxage    led    to    future    date    %s.    Abort    syncing.' % maxagestr), OfflineImapError.ERROR.MESSAGE)
        return date
    except ValueError:
        raise OfflineImapError(('invalid    maxage    value    %s' % maxagestr), OfflineImapError.ERROR.MESSAGE)
