Mercurial > hg > rc1
comparison plugins/libcalendaring/lib/Sabre/VObject/Component/VTodo.php @ 4:888e774ee983
libcalendar plugin as distributed
| author | Charlie Root |
|---|---|
| date | Sat, 13 Jan 2018 08:57:56 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:f6fe4b6ae66a | 4:888e774ee983 |
|---|---|
| 1 <?php | |
| 2 | |
| 3 namespace Sabre\VObject\Component; | |
| 4 | |
| 5 use Sabre\VObject; | |
| 6 | |
| 7 /** | |
| 8 * VTodo component | |
| 9 * | |
| 10 * This component contains some additional functionality specific for VTODOs. | |
| 11 * | |
| 12 * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/). | |
| 13 * @author Evert Pot (http://evertpot.com/) | |
| 14 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License | |
| 15 */ | |
| 16 class VTodo extends VObject\Component { | |
| 17 | |
| 18 /** | |
| 19 * Returns true or false depending on if the event falls in the specified | |
| 20 * time-range. This is used for filtering purposes. | |
| 21 * | |
| 22 * The rules used to determine if an event falls within the specified | |
| 23 * time-range is based on the CalDAV specification. | |
| 24 * | |
| 25 * @param DateTime $start | |
| 26 * @param DateTime $end | |
| 27 * @return bool | |
| 28 */ | |
| 29 public function isInTimeRange(\DateTime $start, \DateTime $end) { | |
| 30 | |
| 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; | |
| 36 | |
| 37 if ($dtstart) { | |
| 38 if ($duration) { | |
| 39 $effectiveEnd = clone $dtstart; | |
| 40 $effectiveEnd->add($duration); | |
| 41 return $start <= $effectiveEnd && $end > $dtstart; | |
| 42 } elseif ($due) { | |
| 43 return | |
| 44 ($start < $due || $start <= $dtstart) && | |
| 45 ($end > $dtstart || $end >= $due); | |
| 46 } else { | |
| 47 return $start <= $dtstart && $end > $dtstart; | |
| 48 } | |
| 49 } | |
| 50 if ($due) { | |
| 51 return ($start < $due && $end >= $due); | |
| 52 } | |
| 53 if ($completed && $created) { | |
| 54 return | |
| 55 ($start <= $created || $start <= $completed) && | |
| 56 ($end >= $created || $end >= $completed); | |
| 57 } | |
| 58 if ($completed) { | |
| 59 return ($start <= $completed && $end >= $completed); | |
| 60 } | |
| 61 if ($created) { | |
| 62 return ($end > $created); | |
| 63 } | |
| 64 return true; | |
| 65 | |
| 66 } | |
| 67 | |
| 68 } |
