6 * This component contains some additional functionality specific for VTODOs.
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_VTodo 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) {
29 $dtstart = isset($this->DTSTART)?$this->DTSTART->getDateTime():null;
30 $duration = isset($this->DURATION)?Sabre_VObject_DateTimeParser::parseDuration($this->DURATION):null;
31 $due = isset($this->DUE)?$this->DUE->getDateTime():null;
32 $completed = isset($this->COMPLETED)?$this->COMPLETED->getDateTime():null;
33 $created = isset($this->CREATED)?$this->CREATED->getDateTime():null;
37 $effectiveEnd = clone $dtstart;
38 $effectiveEnd->add($duration);
39 return $start <= $effectiveEnd && $end > $dtstart;
42 ($start < $due || $start <= $dtstart) &&
43 ($end > $dtstart || $end >= $due);
45 return $start <= $dtstart && $end > $dtstart;
49 return ($start < $due && $end >= $due);
51 if ($completed && $created) {
53 ($start <= $created || $start <= $completed) &&
54 ($end >= $created || $end >= $completed);
57 return ($start <= $completed && $end >= $completed);
60 return ($end > $created);