static function IsShowingCurrentServicePeriod($date = false) { $requested = Page::GetRequestedServicePeriod($date); $current = ServicePeriod::GetServicePeriod(); if (empty($requested) || empty($current)) { return false; } else { return Page::GetRequestedServicePeriod($date)->GetID() == ServicePeriod::GetServicePeriod()->GetID(); } }
public static function GetServicePeriod($date = false) { // specify $date == false to get current service period if ($date !== false && is_int($date) === false) { throw new InvalidArgumentException('$date must be false or a valid UNIX integer timestamp, value provided: ' . $date); } if (($date === false || $date - 10 * 60 <= self::$currentSPtimestamp) && self::$currentSPtimestamp <= time() - 10 * 60) { // early return without querying to save time return self::$currentSP; } $servicePeriods = self::GetAllServicePeriods(); foreach ($servicePeriods as $sp) { if ($sp->IsActive($date) === true) { if ($date === false || $date >= time() - 10 * 60) { // if we were looking for the *current* ServicePeriod, // save it for future references within the same page load self::$currentSP = $sp; self::$currentSPtimestamp = time(); } return $sp; } } return false; // no valid service period for requested/current timestamp was found }
<?php include_once '../common/headers.php'; echo '<a href="createDirection.php">Insert directions for routes</a><br /><br />'; echo '<a href="view.php">View existing routes and directions</a><br />'; exit; print 'Select route:<br/>'; $route = new Route('12'); $route->long_name = 'Conestoga Mall/Fairview Mall'; $route->short_name = '12'; //$route->WriteToDatabase(); $Routes = Route::GetAllRoutes(); $dd = new DropDown('routeID', $Routes); $dd->Write(); $ddsp = new DropDown('servicePeriod', ServicePeriod::GetAllServicePeriods()); $ddsp->Write(); echo '<pre>'; print Route::WriteGTFSHeader(); foreach ($Routes as $route) { print $route->WriteToGTFS(); } print '<br/><br/><br/>Query count: ' . $Database->GetQueryCount();