ical-expander icon indicating copy to clipboard operation
ical-expander copied to clipboard

Get currently running events

Open sumbbl145 opened this issue 6 years ago • 5 comments

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())

sumbbl145 avatar Dec 07 '18 01:12 sumbbl145

Shouldn't be too hard to implement! PR welcome :)

mifi avatar Dec 20 '18 07:12 mifi

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());
    }

paustint avatar Jan 18 '19 03:01 paustint

Could be! Someone 🙈 just needs to write some tests to verify all scenarios (time after, time before, time within event, full day)

mifi avatar Jan 27 '19 13:01 mifi

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());
}

radarfox avatar Apr 15 '20 08:04 radarfox

Sure. PR welcome!

mifi avatar Apr 24 '20 14:04 mifi