/** * Returns a normalised list of periods representing the consumed time for this event. * @param rangeStart the start of a range * @param rangeEnd the end of a range * @return a normalised list of periods representing consumed time for this event * @see VEvent#getConsumedTime(Date, Date, boolean) */ public final PeriodList getConsumedTime(final Date rangeStart, final Date rangeEnd) { return getConsumedTime(rangeStart, rangeEnd, true); }
/** * Returns a normalised list of periods representing the consumed time for this event. * @param rangeStart the start of a range * @param rangeEnd the end of a range * @return a normalised list of periods representing consumed time for this event * @see VEvent#getConsumedTime(Date, Date, boolean) */ public final PeriodList getConsumedTime(final Date rangeStart, final Date rangeEnd) { return getConsumedTime(rangeStart, rangeEnd, true); }
/** * Returns a normalised list of periods representing the consumed time for this event. * @param rangeStart the start of a range * @param rangeEnd the end of a range * @return a normalised list of periods representing consumed time for this event * @see VEvent#getConsumedTime(Date, Date, boolean) */ public final PeriodList getConsumedTime(final Date rangeStart, final Date rangeEnd) { return getConsumedTime(rangeStart, rangeEnd, true); }
/** * Returns a normalised list of periods representing the consumed time for this event. * @param rangeStart the start of a range * @param rangeEnd the end of a range * @return a normalised list of periods representing consumed time for this event * @see VEvent#getConsumedTime(Date, Date, boolean) */ public final PeriodList getConsumedTime(final Date rangeStart, final Date rangeEnd) { return getConsumedTime(rangeStart, rangeEnd, true); }
/** * Returns a normalised list of periods representing the consumed time for this event. * @param rangeStart the start of a range * @param rangeEnd the end of a range * @return a normalised list of periods representing consumed time for this event * @see VEvent#getConsumedTime(Date, Date, boolean) */ public final PeriodList getConsumedTime(final Date rangeStart, final Date rangeEnd) { return getConsumedTime(rangeStart, rangeEnd, true); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Iterator i = components.getComponents(Component.VEVENT).iterator(); i.hasNext();) { final Component component = (Component) i.next(); periods.addAll(((VEvent) component).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Creates a list of periods representing the time consumed by the specified list of components. * @param components * @return */ private PeriodList getConsumedTime(final ComponentList<CalendarComponent> components, final DateTime rangeStart, final DateTime rangeEnd) { final PeriodList periods = new PeriodList(); // only events consume time.. for (final Component event : components.getComponents(Component.VEVENT)) { periods.addAll(((VEvent) event).getConsumedTime(rangeStart, rangeEnd, false)); } return periods.normalise(); }
/** * Returns a single occurrence of a recurring event. * @param date a date on which the occurence should occur * @return a single non-recurring event instance for the specified date, or null if the event doesn't * occur on the specified date * @throws IOException where an error occurs reading data * @throws URISyntaxException where an invalid URI is encountered * @throws ParseException where an error occurs parsing data */ public final VEvent getOccurrence(final Date date) throws IOException, URISyntaxException, ParseException { final PeriodList consumedTime = getConsumedTime(date, date); for (final Iterator i = consumedTime.iterator(); i.hasNext();) { final Period p = (Period) i.next(); if (p.getStart().equals(date)) { final VEvent occurrence = (VEvent) this.copy(); occurrence.getProperties().add(new RecurrenceId(date)); return occurrence; } } return null; }
public final void testGetConsumedTime2() throws Exception { String resource = "/samples/valid/derryn.ics"; net.fortuna.ical4j.model.Calendar calendar = loadCalendar(resource); Date start = new Date(); Calendar endCal = getCalendarInstance(); endCal.setTime(start); endCal.add(Calendar.WEEK_OF_YEAR, 4); // Date end = new Date(start.getTime() + (1000 * 60 * 60 * 24 * 7 * 4)); calendar.getComponents().forEach(calendarComponent -> { if (calendarComponent instanceof VEvent) { PeriodList consumed = ((VEvent) calendarComponent).getConsumedTime(start, new Date(endCal.getTime().getTime())); log.debug("Event [" + calendarComponent + "]"); log.debug("Consumed time [" + consumed + "]"); } }); }
/** * Test to ensure that EXDATE properties are correctly applied. * * @throws ParseException */ public void testGetConsumedTimeWithExDate2() throws IOException, ParserException { InputStream in = getClass().getResourceAsStream("/samples/valid/friday13.ics"); net.fortuna.ical4j.model.Calendar calendar = new CalendarBuilder().build(in); VEvent event = (VEvent) calendar.getComponent(Component.VEVENT); Calendar cal = Calendar.getInstance(); cal.set(1997, 8, 2); Date start = new Date(cal.getTime()); cal.set(1997, 8, 4); Date end = new Date(cal.getTime()); PeriodList periods = event.getConsumedTime(start, end); assertTrue(periods.isEmpty()); }
/** * Returns a single occurrence of a recurring event. * @param date a date on which the occurence should occur * @return a single non-recurring event instance for the specified date, or null if the event doesn't * occur on the specified date * @throws IOException where an error occurs reading data * @throws URISyntaxException where an invalid URI is encountered * @throws ParseException where an error occurs parsing data */ public final VEvent getOccurrence(final Date date) throws IOException, URISyntaxException, ParseException { final PeriodList consumedTime = getConsumedTime(date, date); for (final Period p : consumedTime) { if (p.getStart().equals(date)) { final VEvent occurrence = (VEvent) this.copy(); occurrence.getProperties().add(new RecurrenceId(date)); return occurrence; } } return null; }
/** * Returns a single occurrence of a recurring event. * @param date a date on which the occurence should occur * @return a single non-recurring event instance for the specified date, or null if the event doesn't * occur on the specified date * @throws IOException where an error occurs reading data * @throws URISyntaxException where an invalid URI is encountered * @throws ParseException where an error occurs parsing data */ public final VEvent getOccurrence(final Date date) throws IOException, URISyntaxException, ParseException { final PeriodList consumedTime = getConsumedTime(date, date); for (final Period p : consumedTime) { if (p.getStart().equals(date)) { final VEvent occurrence = (VEvent) this.copy(); occurrence.getProperties().add(new RecurrenceId(date)); return occurrence; } } return null; }
/** * Returns a single occurrence of a recurring event. * @param date a date on which the occurence should occur * @return a single non-recurring event instance for the specified date, or null if the event doesn't * occur on the specified date * @throws IOException where an error occurs reading data * @throws URISyntaxException where an invalid URI is encountered * @throws ParseException where an error occurs parsing data */ public final VEvent getOccurrence(final Date date) throws IOException, URISyntaxException, ParseException { final PeriodList consumedTime = getConsumedTime(date, date); for (final Period p : consumedTime) { if (p.getStart().equals(date)) { final VEvent occurrence = (VEvent) this.copy(); occurrence.getProperties().add(new RecurrenceId(date)); return occurrence; } } return null; }
/** * Returns a single occurrence of a recurring event. * @param date a date on which the occurence should occur * @return a single non-recurring event instance for the specified date, or null if the event doesn't * occur on the specified date * @throws IOException where an error occurs reading data * @throws URISyntaxException where an invalid URI is encountered * @throws ParseException where an error occurs parsing data */ public final VEvent getOccurrence(final Date date) throws IOException, URISyntaxException, ParseException { final PeriodList consumedTime = getConsumedTime(date, date); for (final Period p : consumedTime) { if (p.getStart().equals(date)) { final VEvent occurrence = (VEvent) this.copy(); occurrence.getProperties().add(new RecurrenceId(date)); return occurrence; } } return null; }
public final void testGetConsumedTime3() throws Exception { String resource = "/samples/valid/calconnect10.ics"; net.fortuna.ical4j.model.Calendar calendar = loadCalendar(resource); VEvent vev = (VEvent) calendar.getComponent(Component.VEVENT); Date start = vev.getStartDate().getDate(); Calendar cal = getCalendarInstance(); cal.add(Calendar.YEAR, 1); Date latest = new Date(cal.getTime()); PeriodList pl = vev.getConsumedTime(start, latest); assertTrue(!pl.isEmpty()); }
/** * Test COUNT rules. */ public void testGetConsumedTimeByCount() { Recur recur = new Recur.Builder().frequency(Frequency.WEEKLY).count(3) .interval(1).dayList(new WeekDayList(SU)).build(); log.info(recur.toString()); Calendar cal = getCalendarInstance(); cal.set(Calendar.DAY_OF_MONTH, 8); Date start = new DateTime(cal.getTime()); // cal.add(Calendar.DAY_OF_WEEK_IN_MONTH, 10); cal.add(Calendar.HOUR_OF_DAY, 1); Date end = new DateTime(cal.getTime()); // log.info(recur.getDates(start, end, Value.DATE_TIME)); RRule rrule = new RRule(recur); VEvent event = new VEvent(start, end, "Test recurrence COUNT"); event.getProperties().add(rrule); log.info(event.toString()); Calendar rangeCal = getCalendarInstance(); Date rangeStart = new DateTime(rangeCal.getTime()); rangeCal.add(Calendar.WEEK_OF_YEAR, 4); Date rangeEnd = new DateTime(rangeCal.getTime()); log.info(event.getConsumedTime(rangeStart, rangeEnd).toString()); }
/** * Test to ensure that EXDATE properties are correctly applied. * * @throws ParseException */ public void testGetConsumedTimeWithExDate() throws ParseException { VEvent event1 = new VEvent(new DateTime("20050103T080000"), java.time.Duration.ofMinutes(15), "Event 1"); Recur rRuleRecur = new Recur("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR"); RRule rRule = new RRule(rRuleRecur); event1.getProperties().add(rRule); ParameterList parameterList = new ParameterList(); parameterList.add(Value.DATE); ExDate exDate = new ExDate(parameterList, "20050106"); event1.getProperties().add(exDate); Date start = new Date("20050106"); Date end = new Date("20050107"); PeriodList list = event1.getConsumedTime(start, end); assertTrue(list.isEmpty()); }