def filtr(mass, days_ago, days_future):
delta1 = timedelta(days=days_ago)
delta2 = timedelta(days=days_future)
delta3 = timedelta(days=1)
new = []
today = datetime.today()
for el in mass:
to_date = datetime.strptime(el['date'], '%Y-%m-%d')
if to_date >= today and (to_date - today) <= delta2:
new.append(el)
elif to_date <= today and (today - to_date) <= delta1+delta3:
new.append(el)
return new