Beginnings of Christmas 2011 support
[busui.git] / include / common-transit.inc.php
blob:a/include/common-transit.inc.php -> blob:b/include/common-transit.inc.php
--- a/include/common-transit.inc.php
+++ b/include/common-transit.inc.php
@@ -18,8 +18,7 @@
 $service_periods = Array(
     'sunday',
     'saturday',
-    'weekday',
-    "Christmas2011","EndOfYearHolidays"
+    'weekday'
 );
 
 function service_period($date = "") {
@@ -33,48 +32,39 @@
         return strtolower($override['service_id']);
     }
     $date = ($date != "" ? $date : time());
-// christmas special cases
-    $ymd = date('Ymd', $date);
     $dow = date('w', $date);
-    if ($ymd == "20111225") {
-        return "Christmas2011";
-    } if ($ymd == "20111228" || $ymd == "20111229" || $ymd == "20111230") {
-        return "EndOfYearHolidays";
-    } else if (intval($ymd) < "20120203" && $dow != 0 && $dow != 6) {
-        return "Weekday-SchoolVacation";
-    } else {
-        switch ($dow) {
-            case 0:
-                return 'sunday';
-            case 6:
-                return 'saturday';
-            default:
-                return 'weekday';
-        }
-    }
-}
-
-function service_ids($service_period) {
+
+    switch ($dow) {
+        case 0:
+            return 'sunday';
+        case 6:
+            return 'saturday';
+        default:
+            return 'weekday';
+    }
+}
+
+function service_ids($service_period, $date = "") {
     switch ($service_period) {
         case 'sunday':
             return Array("Sunday", "Sunday");
         case 'saturday':
             return Array("Saturday", "Saturday");
-        case "Christmas2011":
-            return Array("Christmas2011", "Christmas2011");
-        case "EndOfYearHolidays":
-            return Array("Weekday-EndOfYearHolidays", "Weekday-EndOfYearHolidays");
-        case "Weekday-SchoolVacation":
-            return Array("Weekday", "Weekday-SchoolVacation");
         default:
-            //return 'weekday';
-            return Array("Weekday", "Weekday");
+            $date = ($date != "" ? $date : time());
+// school holidays
+            $ymd = date('Ymd', $date);
+            $dow = date('w', $date);
+            if (intval($ymd) < "20120203" && $dow != 0 && $dow != 6) {
+                return Array("Weekday-SchoolVacation", "Weekday-SchoolVacation");
+            } else {
+                return Array("Weekday", "Weekday");
+            }
     }
 }
 
 function valid_service_ids() {
-    return array_merge(service_ids(""), service_ids('saturday'), service_ids('sunday'),
-            Array("Christmas2011","Weekday-EndOfYearHolidays","Weekday-SchoolVacation"));
+    return array_merge(service_ids(""), service_ids('saturday'), service_ids('sunday'));
 }
 
 function midnight_seconds($time = "") {
@@ -311,5 +301,4 @@
     }
 
 }
-?>
-
+