Commit e0809689 authored by erdnaxe's avatar erdnaxe 🎇

Add events from last week

parent f5c61506
import logging
import re
from datetime import date
from datetime import date, timedelta
from icalendar_tools import get_event_start_date
......@@ -8,11 +8,12 @@ logger = logging.getLogger('Filters')
def filter_date(event) -> bool:
"""Return true if event day is today or in the future"""
"""Return true if event day is after the beginning of last week"""
event_date = get_event_start_date(event)
if event_date:
return event_date >=
from_date = - timedelta(weeks=1)
return event_date >= from_date
# If there is a bug in data then do not filter
summary = event.get('summary')
......@@ -26,7 +26,7 @@ for url in config.calendars_url:
# Copy events
for event in online_calendar.get_events():
# If it is an event in the future and in the correct group
# If it is an event more recent than past week and in the correct group
if filter_date(event) and filter_group(event, config.selected_groups):
logging.debug('An event was added : {}'.format(event.get('summary')))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment