Skip to content

Commit

Permalink
Make sure todays activites are still on screen
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdijk committed Jan 10, 2024
1 parent 45e1db7 commit 68ce344
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions narrowcast_content/upcoming_activities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ def fetch_and_parse_ics(url):
# Function to filter events for the next 7 days
def filter_events_for_next_n_days(events, n):
now = datetime.now(timezone.utc)
end_of_week = now + timedelta(days=n)
start_of_today = now.replace(hour=0, minute=0)
end_of_week = (now + timedelta(days=n)).replace(hour=23, minute=0)

return [
event
for event in events
if now <= event['start'] < end_of_week
if start_of_today <= event['start'] < end_of_week
]


Expand Down

0 comments on commit 68ce344

Please sign in to comment.