-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.php
73 lines (63 loc) · 1.53 KB
/
time.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
function isOpen($hour, $min, $openHour, $openMin, $closeHour, $closeMin, $alwaysOpen)
{
if($alwaysOpen == 1)
{
return true;
}
$lateClosing = false;
$closeHourTemp = $closeHour;
$closeMinTemp = $closeMin;
if($closeHour < $openHour)
{ //Needs to recognize if it "closes" before it opens according to the clock
$lateClosing = true;
$closeHourTemp += 24;
}
if($lateClosing and equalTime($hour, $min, 0, 0))
{
return true;
}
if($lateClosing and lessThanTime($hour, $min, $closeHour, $closeMin) and greaterThanTime($hour, $min, 0, 0))
{ //needs to adjust how the time looks if it is after midnight so it does not auto think it is closed.
//First checks if it closes late, is before closing, and after midnight
$hour += 24;
}
if(greaterThanTime($hour, $min, $openHour, $openMin) and lessThanTime($hour, $min, $closeHourTemp, $closeMinTemp))
{
return true;
}
return false;
}
function lessThanTime($hour1, $min1, $hour2, $min2)
{
if(($hour1 < $hour2) or (($hour1 == $hour2) and ($min1 < $min2)))
{
return true;
}
return false;
}
function equalTime($hour1, $min1, $hour2, $min2)
{
if(($hour1 == $hour2) && ($min1 == $min2))
{
return true;
}
return false;
}
function greaterThanTime($hour1, $min1, $hour2, $min2)
{
if(($hour1 > $hour2) or (($hour1 == $hour2) and ($min1 > $min2)))
{
return true;
}
return false;
}
function greaterThanEqualTime($hour1, $min1, $hour2, $min2)
{
if(($hour1 > $hour2) or (($hour1 == $hour2) and (($min1 > $min2) or ($min1 == $min2))))
{
return true;
}
return false;
}
?>