annotate plugins/libcalendaring/lib/Sabre/VObject/Component/VJournal.php @ 4:888e774ee983

libcalendar plugin as distributed
author Charlie Root
date Sat, 13 Jan 2018 08:57:56 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
1 <?php
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
2
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
3 namespace Sabre\VObject\Component;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
4
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
5 use Sabre\VObject;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
6
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
7 /**
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
8 * VJournal component
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
9 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
10 * This component contains some additional functionality specific for VJOURNALs.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
11 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
12 * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/).
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
13 * @author Evert Pot (http://evertpot.com/)
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
14 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
15 */
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
16 class VJournal extends VObject\Component {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
17
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
18 /**
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
19 * Returns true or false depending on if the event falls in the specified
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
20 * time-range. This is used for filtering purposes.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
21 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
22 * The rules used to determine if an event falls within the specified
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
23 * time-range is based on the CalDAV specification.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
24 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
25 * @param DateTime $start
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
26 * @param DateTime $end
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
27 * @return bool
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
28 */
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
29 public function isInTimeRange(\DateTime $start, \DateTime $end) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
30
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
31 $dtstart = isset($this->DTSTART)?$this->DTSTART->getDateTime():null;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
32 if ($dtstart) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
33 $effectiveEnd = clone $dtstart;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
34 if ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
35 $effectiveEnd->modify('+1 day');
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
36 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
37
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
38 return ($start <= $effectiveEnd && $end > $dtstart);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
39
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
40 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
41 return false;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
42
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
43
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
44 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
45
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
46 }