3 namespace Sabre\VObject\Component;
9 * This component contains some additional functionality specific for VEVENT's.
11 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
12 * @author Evert Pot (http://www.rooftopsolutions.nl/)
13 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
15 class VEvent extends VObject\Component {
18 * Returns true or false depending on if the event falls in the specified
19 * time-range. This is used for filtering purposes.
21 * The rules used to determine if an event falls within the specified
22 * time-range is based on the CalDAV specification.
24 * @param \DateTime $start
25 * @param \DateTime $end
28 public function isInTimeRange(\DateTime $start, \DateTime $end) {
31 $it = new VObject\RecurrenceIterator($this);
32 $it->fastForward($start);
34 // We fast-forwarded to a spot where the end-time of the
35 // recurrence instance exceeded the start of the requested
38 // If the starttime of the recurrence did not exceed the
39 // end of the time range as well, we have a match.
40 return ($it->getDTStart() < $end && $it->getDTEnd() > $start);
44 $effectiveStart = $this->DTSTART->getDateTime();
45 if (isset($this->DTEND)) {
47 // The DTEND property is considered non inclusive. So for a 3 day
48 // event in july, dtstart and dtend would have to be July 1st and
49 // July 4th respectively.
52 // http://tools.ietf.org/html/rfc5545#page-54
53 $effectiveEnd = $this->DTEND->getDateTime();
55 } elseif (isset($this->DURATION)) {
56 $effectiveEnd = clone $effectiveStart;
57 $effectiveEnd->add( VObject\DateTimeParser::parseDuration($this->DURATION) );
58 } elseif ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) {
59 $effectiveEnd = clone $effectiveStart;
60 $effectiveEnd->modify('+1 day');
62 $effectiveEnd = clone $effectiveStart;
65 ($start <= $effectiveEnd) && ($end > $effectiveStart)