Include network wide service alerts in page headers
[busui.git] / include / common-transit.inc.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
<?php
$service_periods = Array(
        'sunday',
        'saturday',
        'weekday'
);
 
function service_period($date = "")
{
        
        if (isset($_SESSION['service_period'])) return $_SESSION['service_period'];
        $override = getServiceOverride($date);
        if ($override['service_id']){
                return $override['service_id'];
        }
 
        switch (date('w',($date != "" ? $date : time()))) {
        case 0:
                return 'sunday';
        case 6:
                return 'saturday';
        default:
                return 'weekday';
        }
}
function midnight_seconds($time = "")
{
        // from http://www.perturb.org/display/Perlfunc__Seconds_Since_Midnight.html
        if ($time != "") {
                return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time);
        }
        if (isset($_SESSION['time'])) {
                $time = strtotime($_SESSION['time']);
                return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time);
        }
        return (date("G") * 3600) + (date("i") * 60) + date("s");
}
function midnight_seconds_to_time($seconds)
{
        if ($seconds > 0) {
                $midnight = mktime(0, 0, 0, date("n") , date("j") , date("Y"));
                return date("h:ia", $midnight + $seconds);
        }
        else {
                return "";
        }
}
?>