Introduce a function that filters events by time

Currently we have four places where we filter events by start and date: let's use a centralized function (`getEventsBetween(start, end)`) to do that.