$helper->data['ScheduledArrival'] = ParseTime(substr($line, 10, 5)); $helper->data['PublicArrival'] = ParseTime(substr($line, 15, 4)); $helper->data['Platform'] = trim(substr($line, 19, 3)); $helper->data['Path'] = trim(substr($line, 22, 3)); $helper->SaveRecord(); $lastLocation = $helper->data['Location']; $lastSuffix = $helper->data['LocationSuffix']; $activity = str_split(substr($line, 25, 12), 2); foreach ($activity as $act) { $act = trim($act); if (!empty($act)) { $helper2 = new DataHelper("tblActivity", "ActivityID"); $helper2->data['JourneyID'] = $helper->data['JourneyDestinationID']; $helper2->data['JourneyType'] = 'Destination'; $helper2->data['Activity'] = $act; $helper2->SaveRecord(); } } break; } } // takes a 2 digit time string with possible // half minutes and creates a mysql string function ParseWait($time) { if (substr($time, 1, 1) == 'H') { return "00:0" . substr($time, 0, 1) . ":30"; } else { return "00:" . $time; } }
$helper->data['Location'] = substr($line, 2, 12); $helper->data['ArrivalTime'] = ParseTime(substr($line, 14, 4)); $helper->data['BayNumber'] = substr($line, 18, 3); $helper->data['TimingPoint'] = substr($line, 21, 2) == "T1" ? "Timing Point" : "Not Timing Point"; $helper->data['FareStage'] = substr($line, 21, 2) == "F1" ? "Fare Stage" : "Not Fare Stage"; $helper->SaveRecord(); break; case "QR": $helper = new DataHelper("tblJourneyRepetition", "JourneyRepetitionID"); $helper->data['DuplicatedJourneyIdentifier'] = $lastJourney; $helper->data['Location'] = substr($line, 2, 12); $helper->data['DepartureTime'] = ParseTime(substr($line, 14, 4)); $helper->data['UniqueJourneyIdentifier'] = substr($line, 18, 6); $helper->data['RunningBoard'] = substr($line, 24, 6); $helper->data['VehicleType'] = substr($line, 30, 8); $helper->SaveRecord(); break; } } } // takes a translink 8 digit date string // and creates a mysql formatted string function ParseDate($date) { $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); return $year . "-" . $month . "-" . $day; } // takes a translink 6 or 4 digit time string // and creates a mysql formatted time