3 namespace Sabre\VObject\Component;
10 * This component contains some additional functionality specific for VTODOs.
12 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
13 * @author Evert Pot (http://www.rooftopsolutions.nl/)
14 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
16 class VTodo extends VObject\Component {
19 * Returns true or false depending on if the event falls in the specified
20 * time-range. This is used for filtering purposes.
22 * The rules used to determine if an event falls within the specified
23 * time-range is based on the CalDAV specification.
25 * @param DateTime $start
26 * @param DateTime $end
29 public function isInTimeRange(\DateTime $start, \DateTime $end) {
31 $dtstart = isset($this->DTSTART)?$this->DTSTART->getDateTime():null;
32 $duration = isset($this->DURATION)?VObject\DateTimeParser::parseDuration($this->DURATION):null;
33 $due = isset($this->DUE)?$this->DUE->getDateTime():null;
34 $completed = isset($this->COMPLETED)?$this->COMPLETED->getDateTime():null;
35 $created = isset($this->CREATED)?$this->CREATED->getDateTime():null;
39 $effectiveEnd = clone $dtstart;
40 $effectiveEnd->add($duration);
41 return $start <= $effectiveEnd && $end > $dtstart;
44 ($start < $due || $start <= $dtstart) &&
45 ($end > $dtstart || $end >= $due);
47 return $start <= $dtstart && $end > $dtstart;
51 return ($start < $due && $end >= $due);
53 if ($completed && $created) {
55 ($start <= $created || $start <= $completed) &&
56 ($end >= $created || $end >= $completed);
59 return ($start <= $completed && $end >= $completed);
62 return ($end > $created);