예제 #1
0
파일: class.peer.php 프로젝트: LX3JL/xlxd
 public function __construct($Callsign, $IP, $LinkedModule, $Protocol, $ConnectTime, $LastHeardTime)
 {
     $this->IP = $IP;
     $this->Protocol = $Protocol;
     $this->ConnectTime = ParseTime($ConnectTime);
     $this->LastHeardTime = ParseTime($LastHeardTime);
     $this->Callsign = trim($Callsign);
     $this->LinkedModule = trim($LinkedModule);
 }
예제 #2
0
 public function __construct($Callsign, $Via, $Peer, $LastHeardTime)
 {
     $this->Callsign = trim($Callsign);
     $this->Via = trim($Via);
     $this->Peer = trim($Peer);
     $this->LastHeardTime = ParseTime($LastHeardTime);
     if (strpos($Callsign, " / ") !== false) {
         $this->Suffix = trim(substr($Callsign, strpos($Callsign, " / ") + 3, strlen($Callsign)));
     } else {
         $this->Suffix = "";
     }
     $tmp = explode(" ", $Callsign);
     $this->CallsignOnly = $tmp[0];
 }
예제 #3
0
파일: class.node.php 프로젝트: LX3JL/xlxd
 public function __construct($Callsign, $IP, $LinkedModule, $Protocol, $ConnectTime, $LastHeardTime)
 {
     $this->IP = $IP;
     $this->Protocol = $Protocol;
     $this->ConnectTime = ParseTime($ConnectTime);
     $this->LastHeardTime = ParseTime($LastHeardTime);
     $this->FullCallsign = trim(str_replace("   ", "-", $Callsign));
     $this->FullCallsign = str_replace("  ", "-", $this->FullCallsign);
     $this->FullCallsign = str_replace(" ", "-", $this->FullCallsign);
     if (strpos($Callsign, " ") !== false) {
         $this->Callsign = trim(substr($Callsign, 0, strpos($Callsign, " ")));
         $this->Suffix = trim(substr($Callsign, strpos($Callsign, " "), strlen($Callsign)));
         $this->Prefix = strtoupper(trim(substr($Callsign, 0, 3)));
     } else {
         $this->Callsign = trim($Callsign);
         $this->Suffix = "";
         $this->Prefix = "";
     }
     $this->LinkedModule = trim($LinkedModule);
 }
예제 #4
0
             $helper2 = new DataHelper("tblActivity", "ActivityID");
             $helper2->data['JourneyID'] = $helper->data['JourneyIntermediateID'];
             $helper2->data['JourneyType'] = 'Intermediate';
             $helper2->data['Activity'] = $act;
             $helper2->SaveRecord();
         }
     }
     break;
 case "LT":
     $helper = new DataHelper("tblJourneyDestination", "JourneyDestinationID");
     $helper->data['UniqueJourneyIdentifier'] = $lastJourney;
     $helper->data['ProviderJourneyIdentifier'] = $lastProvJourney;
     $helper->data['Location'] = substr($line, 2, 7);
     $helper->data['LocationSuffix'] = substr($line, 9, 1);
     $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();
         }
예제 #5
0
function ParseTime_Tests($now = null)
{
    while (ob_get_level()) {
        ob_end_clean();
    }
    header("Content-Encoding: none");
    ob_start();
    // + 12d, +12d, + 12d, +12 day, +12 days = time() + 12 days
    // + -5h = time() - 5 hours
    // + 1y - 5d + 5h = time() + 1year - 5 days + 5 hours
    // + -5d 15:55 = time() - 5 days
    // + -1week 12:00, -1 Week 12:00, - 1 week 12:00:53
    // + -1w
    $tests = array("now", " now", "now()", "time", "NOW()", "TIME()", "unix_timestamp", "current_timestamp", "Today", "teraz", "dzisiaj", "dzis", "now 13:00", "now  13:13", "Today 13:13:13", "dzisiaj 13:13:13", "teraz 13:13", "dzis 13:13", "yesterday", "Wczoraj", "Tomorrow", "jutro", "yesterday 13:13", "Yesterday 13:13:13", "Wczoraj 13:13", "Tomorrow 13:13", "tomorrow 13:13:13", "jutro 13:13", "pojutrze", "pojutrze 13:13", "przedwczoraj", "przedwczoraj 13:13", "2013-12-13", "2013-12-13 13:13", "2013-12-13 13:13:13", "2011-13-13", "2011-12-33", "13.12", "13.12 13:13", "13.12 13:13:13", "13.12.2013", "13.12.2013 13:13", "13.12.2013 13:13:13", "13:13", "12d", "12 dni", "+ 12 dni", "-1year", "teraz -1year", "dzisiaj 12:00 -1year", "-1month", "+1 month", "+2month", "+3month", "+4m", "+5m", "1d -5h", "1y - 5d + 5h", "1y -5 Dni", "-1 tydzien 13:13", "-1w", "wczoraj +1h", "wczoraj -1h", "jutro +1dzien", "+12m", "+13m", "+24m", "+25m", "+36m", "+37m", "+48m", "+49m", "1st february", "1 february", "2nd Feb", "3rd Feb", "4th Feb 2013", "15 stycznia", "stycznia", "styczeń 15:00", "15 styczeń", "15 sty", "12 lutego", "12 luty", "12 Lut", "15 styczeń o 17:00", "21 styczen 2010", "21szy stycznia", "21-szy stycznia", "21st January", "21 January", "monday 15:00", "tuesday 15:00", "poniedziałek 15:00", "wtorek 15:00", "+1 saturday 15:00", "+2 saturday", "in 2 days at 15:00", "za 2 dni o 15:00", "za 3 dni i 5 godzin", "in 2 days and 5 hours", "+2days +5hours", "+0h", "5 godzin", "5 minut", "5 sekund", "za tydzień", "za 2 tygodnie", "next monday", "prev monday", "previous monday", "last monday", "następny poniedziałek", "poprzedni poniedziałek", "ostatni poniedziałek", "+1mon", "+1 tue", "next wed", "next Wed 15:00", "+1pon", "+1 wto", "następny Pon");
    // "15 styczeń o 17:00", "21 styczen 2010", "15 stycznia"
    // Day of week, the nearest one but not including the current one.
    // "saturday 15:00" == on friday it means "+1day 15:00" or "tomorrow 15:00"
    // "saturday 15:00" == on saturday it means next saturday
    // "+1 saturday 15:00" == next saturday, on friday it means "+1 day"
    // "+2 saturday" == saturday after next saturday, on friday it means ""
    // "in 2days at 15:00", "za 2 dni o 15:00"
    // "za 3 dni i 5 godzin" == "+3dni+5godz"
    // "dzien i 2 godziny", "0dni 0godz 1 sekunda"
    printf("<title>Natural time strings</title>");
    printf("<meta charset=utf-8>");
    printf("<style type=text/css>html, body { margin: 0; padding: 0; } body { margin: 1em 1.5em; padding: 0em; } body, table { font: 11px Tahoma; } body { line-height: 1.4em; } h1 { font: bold 15px Tahoma; }</style>");
    printf("<h1>Natural time strings</h1>");
    printf("<div>In fields of type <b>INT</b> you can use natural string times to generate <b>Unix Timestamps</b>.</div>");
    printf("<div>You can also use this strings in fields of type <b>DATETIME</b> and <b>TIMESTAMP</b>.</div>");
    printf("<div>Supported languages are: <b>English</b> and <b>Polish</b>.<div><br>");
    printf("<style type=text/css>th { background: #ddd; padding: 2px 4px;  } td { background: #f5f5f5; padding: 2px 4px; }</style>");
    printf("<table cellspacing=1 cellpadding=0>");
    printf("<tr><th>String</th><th>Date</th></tr>");
    $no = 0;
    foreach ($tests as $string) {
        ++$no;
        $result_time = ParseTime($string, $now);
        $result = date("Y-m-d H:i:s", $result_time);
        if ($result_time == 0) {
            $result = 0;
        }
        printf("<tr><td>%s</td><td>%s</td></tr>", $string, $result);
    }
    printf("</table><br>");
    exit;
}
예제 #6
0
                break;
            case "QT":
                $helper = new DataHelper("tblJourneyDestination", "JourneyDestinationID");
                $helper->data['UniqueJourneyIdentifier'] = $lastJourney;
                $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);