import logging
import re
+import time
_all_conditions = {}
be filtered by the IMAP server.
Arguments:
- sent-before: <string>
- The reference date. The format is day-month-year, with:
+ date: [optional] <string>
+ The absolute date. The format is day-month-year, with:
day = 2 digits, month = 3 letter string (Jan, Feb, Mar, Apr,
May, Jun, Jul, Aug, Sep, Oct, Nov, Dec), year = 4 digits.
+ If date is specified, reldate must not be set.
+ reldate: [optional] <string>
+ The relative date. The format is a integer followed by a
+ letter ('y' year, 'm' month, 'w' week, 'd' days).
+ If reldate is specified, date must not be set.
Example:
sent-before: {date: 28-Oct-2015}
+ sent-before: {reldate: 1m}
"""
name = "sent-before"
- def __init__(self, date):
+ def __init__(self, **kwargs):
+ date = kwargs.get("date", None)
+ reldate = kwargs.get("reldate", None)
+ if date is not None and reldate is not None:
+ raise ValueError("cannot set date and reldate at the same time")
+ if date is None and reldate is None:
+ raise ValueError("no date specified")
+ if reldate:
+ t = time.time()
+ t -= int(reldate) * 3600 * 24 # XXX
+ t = time.gmtime(t)
+ month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
+ "Sep", "Oct", "Nov", "Dec"][t.tm_mon]
+ date = "%d-%s-%d" %(t.tm_mday, month, t.tm_year)
ImapamiCond.__init__(self, criteria=set(['SENTBEFORE "%s"' % date]))
register(ImapamiCondSentBefore)
be filtered by the IMAP server.
Arguments:
- sent-on: <string>
+ date: <string>
The reference date. The format is day-month-year, with:
day = 2 digits, month = 3 letter string (Jan, Feb, Mar, Apr,
May, Jun, Jul, Aug, Sep, Oct, Nov, Dec), year = 4 digits.
be filtered by the IMAP server.
Arguments:
- sent-since: <string>
+ date: <string>
The reference date. The format is day-month-year, with:
day = 2 digits, month = 3 letter string (Jan, Feb, Mar, Apr,
May, Jun, Jul, Aug, Sep, Oct, Nov, Dec), year = 4 digits.