added younger than routines
This commit is contained in:
parent
33ce737b57
commit
54604011b3
45
archivemail
45
archivemail
|
|
@ -1012,11 +1012,17 @@ def should_archive(message):
|
||||||
old = is_older_than_days(time_message, options.days_old_max)
|
old = is_older_than_days(time_message, options.days_old_max)
|
||||||
else:
|
else:
|
||||||
old = is_older_than_time(time_message, options.date_old_max)
|
old = is_older_than_time(time_message, options.date_old_max)
|
||||||
|
if options.date_old_min == None:
|
||||||
|
new = is_younger_than_days(time_message, options.days_old_min)
|
||||||
|
else:
|
||||||
|
new = is_younger_than_time(time_message, options.date_old_min)
|
||||||
|
|
||||||
# I could probably do this in one if statement, but then I wouldn't
|
# I could probably do this in one if statement, but then I wouldn't
|
||||||
# understand it.
|
# understand it.
|
||||||
if not old:
|
if not old:
|
||||||
return False
|
return False
|
||||||
|
if not new:
|
||||||
|
return False
|
||||||
if not options.include_flagged and is_flagged(message):
|
if not options.include_flagged and is_flagged(message):
|
||||||
return False
|
return False
|
||||||
if options.min_size and is_smaller(message, options.min_size):
|
if options.min_size and is_smaller(message, options.min_size):
|
||||||
|
|
@ -1065,6 +1071,45 @@ def is_older_than_days(time_message, max_days):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_younger_than_time(time_message, min_time):
|
||||||
|
"""Return true if a message is newer than the specified time,
|
||||||
|
false otherwise.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
time_message -- the delivery date of the message measured in seconds
|
||||||
|
since the epoch
|
||||||
|
min_time -- minimum time allowed for message
|
||||||
|
|
||||||
|
"""
|
||||||
|
days_old = (min_time - time_message) / 24 / 60 / 60
|
||||||
|
if time_message >= min_time:
|
||||||
|
vprint("message is %.2f days newer than the specified date" % days_old)
|
||||||
|
return True
|
||||||
|
vprint("message is %.2f days older than the specified date" % \
|
||||||
|
abs(days_old))
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def is_younger_than_days(time_message, min_days):
|
||||||
|
"""Return true if a message is newer than the specified number of days,
|
||||||
|
false otherwise.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
time_message -- the delivery date of the message measured in seconds
|
||||||
|
since the epoch
|
||||||
|
min_days -- minimum number of days before message is considered old
|
||||||
|
"""
|
||||||
|
time_now = time.time()
|
||||||
|
if time_message > time_now:
|
||||||
|
vprint("warning: message has date in the future")
|
||||||
|
return False
|
||||||
|
secs_old_min = (min_days * 24 * 60 * 60)
|
||||||
|
days_old = (time_now - time_message) / 24 / 60 / 60
|
||||||
|
vprint("message is %.2f days old" % days_old)
|
||||||
|
if ((time_message + secs_old_min) >= time_now):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def build_imap_filter():
|
def build_imap_filter():
|
||||||
"""Return an imap filter string"""
|
"""Return an imap filter string"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue