ical-expander
ical-expander copied to clipboard
Get currently running events
Is there an ability to get currently running events, perhaps with IcalExpander.now()?
things now() would catch for all events (including recurring):
- events running all day for that day
- events running at that particular time (startDate <= now() && endDate >= now())
Shouldn't be too hard to implement! PR welcome :)
Wouldn't this be solved by passing the same date for start/end times?
Example:
const events = icalExpander.between(
new Date(),
new Date()
);
Existing code seems to cover the use-case (as also depicted in the diagram in the README)
// After and before are just the params passed in to between(before, after)
function isEventWithinRange(startTime, endTime) {
return (!after || endTime >= after.getTime()) &&
(!before || startTime <= before.getTime());
}
Could be! Someone 🙈 just needs to write some tests to verify all scenarios (time after, time before, time within event, full day)
Here is an another idea, that would also cover my use-case of finding the events at the specific date and time:
at(date) {
return this.between(date, date);
}
now() {
return this.at(new Date());
}
Sure. PR welcome!