6 * This component contains some additional functionality specific for VEVENT's.
10 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
11 * @author Evert Pot (http://www.rooftopsolutions.nl/)
12 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14 class Sabre_VObject_Component_VEvent extends Sabre_VObject_Component {
17 * Returns true or false depending on if the event falls in the specified
18 * time-range. This is used for filtering purposes.
20 * The rules used to determine if an event falls within the specified
21 * time-range is based on the CalDAV specification.
23 * @param DateTime $start
24 * @param DateTime $end
27 public function isInTimeRange(DateTime $start, DateTime $end) {
30 $it = new Sabre_VObject_RecurrenceIterator($this);
31 $it->fastForward($start);
33 // We fast-forwarded to a spot where the end-time of the
34 // recurrence instance exceeded the start of the requested
37 // If the starttime of the recurrence did not exceed the
38 // end of the time range as well, we have a match.
39 return ($it->getDTStart() < $end && $it->getDTEnd() > $start);
43 $effectiveStart = $this->DTSTART->getDateTime();
44 if (isset($this->DTEND)) {
45 $effectiveEnd = $this->DTEND->getDateTime();
46 // If this was an all-day event, we should just increase the
47 // end-date by 1. Otherwise the event will last until the second
48 // the date changed, by increasing this by 1 day the event lasts
49 // all of the last day as well.
50 if ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) {
51 $effectiveEnd->modify('+1 day');
53 } elseif (isset($this->DURATION)) {
54 $effectiveEnd = clone $effectiveStart;
55 $effectiveEnd->add( Sabre_VObject_DateTimeParser::parseDuration($this->DURATION) );
56 } elseif ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) {
57 $effectiveEnd = clone $effectiveStart;
58 $effectiveEnd->modify('+1 day');
60 $effectiveEnd = clone $effectiveStart;
63 ($start <= $effectiveEnd) && ($end > $effectiveStart)