forked from humhub/calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalendarUtils.php
57 lines (47 loc) · 1.46 KB
/
CalendarUtils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* HumHub
* Copyright © 2014 The HumHub Project
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*/
/**
* Description of CalendarUtils
*
* @author luke
*/
class CalendarUtils
{
/**
*
* @param DateTime $date1
* @param DateTime $date2
* @param type $endDateMomentAfter
* @return boolean
*/
public static function isFullDaySpan(DateTime $date1, DateTime $date2, $endDateMomentAfter = false)
{
$dateInterval = $date1->diff($date2, true);
if ($endDateMomentAfter) {
if ($dateInterval->days > 0 && $dateInterval->h == 0 && $dateInterval->i == 0 && $dateInterval->s == 0) {
return true;
}
} else {
if ($dateInterval->h == 23 && $dateInterval->i == 59) {
return true;
}
}
return false;
}
}