Im currently using a library called biweekly to parse iCal events in java. I have no issue swapping libraries if a better solution is present so all java related solutions would be welcome.
Im trying to create a function that checks an iCal schedule to work out if any events are currently in progress
/ active
.
Biweekly helped cleanly parse the iCal schedule events like this:
List<ICalendar> icals = Biweekly.parse(schedule).all();
for (ICalendar ical : icals) {
for (VEvent event : ical.getEvents()) {
// I need to compute if the event is currently active
}
}
We found an example that helps get the events as a DateIterator
but we can't as yet connect that to knowing if an event is currently active.
TimezoneInfo tzInfo = ical.getTimezoneInfo();
DateStart dateStart = event.getDateStart();
TimeZone timezone;
if (tzInfo.isFloating(dateStart)){
timezone = TimeZone.getDefault();
} else {
TimezoneAssignment timezoneAssignment = tzInfo.getTimezone(dateStart);
timezone = (timezoneAssignment == null) ? TimeZone.getTimeZone("UTC") :
timezoneAssignment.getTimeZone();
}
DateIterator it = event.getDateIterator(timezone);