当前位置: 首页>>代码示例>>PHP>>正文


PHP tools::transformtime方法代码示例

本文整理汇总了PHP中tools::transformtime方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::transformtime方法的具体用法?PHP tools::transformtime怎么用?PHP tools::transformtime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tools的用法示例。


在下文中一共展示了tools::transformtime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseData

 /**
  * @param $xml
  * @param $time
  * @param $lang
  * @param bool $fast
  * @param bool $showAlerts
  * @return array
  */
 private static function parseData($xml, $time, $lang, $fast = false, $showAlerts = false)
 {
     //clean XML
     if (class_exists('tidy', false)) {
         $tidy = new tidy();
         $tidy->parseString($xml, ['input-xml' => true, 'output-xml' => true], 'utf8');
         $tidy->cleanRepair();
         $xml = $tidy;
     }
     $data = new SimpleXMLElement($xml);
     $hour = substr($time, 0, 2);
     $data = $data->StationTable;
     //<Journey fpTime="08:36" fpDate="03/09/11" delay="-"
     //platform="2" targetLoc="Gent-Dampoort [B]" prod="L    758#L"
     //dir="Eeklo [B]" is_reachable="0" />
     $nodes = [];
     $i = 0;
     $hour = substr($time, 0, 2);
     $hour_ = substr((string) $data->Journey[0]['fpTime'], 0, 2);
     if ($hour_ != '23' && $hour == '23') {
         $hour_ = 24;
     }
     $minutes = substr($time, 3, 2);
     $minutes_ = substr((string) $data->Journey[0]['fpTime'], 3, 2);
     while (isset($data->Journey[$i]) && ($hour_ - $hour) * 60 + ($minutes_ - $minutes) <= 60) {
         $journey = $data->Journey[$i];
         $left = 0;
         $canceled = false;
         $delay = (string) $journey['delay'];
         if ($delay == '-') {
             $delay = '0';
         }
         if ($delay == 'cancel') {
             $delay = 0;
             $canceled = true;
         }
         if (isset($journey['e_delay'])) {
             $delay = $journey['e_delay'] * 60;
         }
         preg_match("/\\+\\s*(\\d+)/", $delay, $d);
         if (isset($d[1])) {
             $delay = $d[1] * 60;
         }
         preg_match("/\\+\\s*(\\d):(\\d+)/", $delay, $d);
         if (isset($d[1])) {
             $delay = $d[1] * 3600 + $d[2] * 60;
         }
         $platform = '?';
         // Indicate to end user platform is unknown
         $platformNormal = true;
         if (isset($journey['platform'])) {
             $platform = (string) $journey['platform'];
         }
         if (isset($journey['newpl'])) {
             $platform = (string) $journey['newpl'];
             $platformNormal = false;
         }
         $time = '00d' . (string) $journey['fpTime'] . ':00';
         preg_match("/(..)\\/(..)\\/(..)/si", (string) $journey['fpDate'], $dayxplode);
         $dateparam = '20' . $dayxplode[3] . $dayxplode[2] . $dayxplode[1];
         $unixtime = tools::transformtime($time, $dateparam);
         if ($fast) {
             $stationNode = new Station();
             $stationNode->name = (string) $journey['targetLoc'];
             $stationNode->name = str_replace(' [B]', '', $stationNode->name);
             $stationNode->name = str_replace(' [NMBS/SNCB]', '', $stationNode->name);
         } else {
             $stationNode = stations::getStationFromName($journey['targetLoc'], $lang);
         }
         $veh = $journey['hafasname'];
         $veh = substr($veh, 0, 8);
         $veh = str_replace(' ', '', $veh);
         $vehicle = 'BE.NMBS.' . $veh;
         $nodes[$i] = new DepartureArrival();
         $nodes[$i]->delay = $delay;
         $nodes[$i]->station = $stationNode;
         $nodes[$i]->time = $unixtime;
         $nodes[$i]->vehicle = $vehicle;
         $nodes[$i]->platform = new Platform();
         $nodes[$i]->platform->name = $platform;
         $nodes[$i]->platform->normal = $platformNormal;
         $nodes[$i]->canceled = $canceled;
         $nodes[$i]->left = $left;
         $hour_ = substr((string) $data->Journey[$i]['fpTime'], 0, 2);
         if ($hour_ != '23' && $hour == '23') {
             $hour_ = 24;
         }
         $minutes_ = substr((string) $data->Journey[$i]['fpTime'], 3, 2);
         // Alerts
         if ($showAlerts && isset($journey->HIMMessage)) {
             $alerts = [];
             $himmessage = $journey->HIMMessage;
//.........这里部分代码省略.........
开发者ID:jncn,项目名称:iRail,代码行数:101,代码来源:liveboard.php

示例2: parseData

 /**
  * @param $xml
  * @param $time
  * @param $lang
  * @param bool $fast
  * @return array
  */
 private static function parseData($xml, $time, $lang, $fast = false)
 {
     //clean XML
     if (class_exists("tidy", false)) {
         $tidy = new tidy();
         $tidy->parseString($xml, ['input-xml' => true, 'output-xml' => true], 'utf8');
         $tidy->cleanRepair();
         $xml = $tidy;
     }
     $data = new SimpleXMLElement($xml);
     $hour = substr($time, 0, 2);
     $data = $data->StationTable;
     //<Journey fpTime="08:36" fpDate="03/09/11" delay="-"
     //platform="2" targetLoc="Gent-Dampoort [B]" prod="L    758#L"
     //dir="Eeklo [B]" is_reachable="0" />
     $nodes = [];
     $i = 0;
     $hour = substr($time, 0, 2);
     $hour_ = substr((string) $data->Journey[0]["fpTime"], 0, 2);
     if ($hour_ != "23" && $hour == "23") {
         $hour_ = 24;
     }
     $minutes = substr($time, 3, 2);
     $minutes_ = substr((string) $data->Journey[0]["fpTime"], 3, 2);
     while (isset($data->Journey[$i]) && ($hour_ - $hour) * 60 + ($minutes_ - $minutes) <= 60) {
         $journey = $data->Journey[$i];
         $left = 0;
         $delay = (string) $journey["delay"];
         if ($delay == "-") {
             $delay = "0";
         }
         $platform = "";
         if (isset($journey["platform"])) {
             $platform = (string) $journey["platform"];
         }
         $time = "00d" . (string) $journey["fpTime"] . ":00";
         preg_match("/(..)\\/(..)\\/(..)/si", (string) $journey["fpDate"], $dayxplode);
         $dateparam = "20" . $dayxplode[3] . $dayxplode[2] . $dayxplode[1];
         $unixtime = tools::transformtime($time, $dateparam);
         //GET DELAY
         preg_match("/\\+\\s*(\\d+)/", $delay, $d);
         if (isset($d[1])) {
             $delay = $d[1] * 60;
         }
         preg_match("/\\+\\s*(\\d):(\\d+)/", $delay, $d);
         if (isset($d[1])) {
             $delay = $d[1] * 3600 + $d[2] * 60;
         }
         if ($fast) {
             $stationNode = new Station();
             $stationNode->name = (string) $journey["dir"];
             $stationNode->name = str_replace(" [B]", "", $stationNode->name);
             $stationNode->name = str_replace(" [NMBS/SNCB]", "", $stationNode->name);
         } else {
             $stationNode = stations::getStationFromName($journey["dir"], $lang);
         }
         //GET VEHICLE AND PLATFORM
         $platformNormal = true;
         $veh = $journey["hafasname"];
         $veh = substr($veh, 0, 8);
         $veh = str_replace(" ", "", $veh);
         $vehicle = "BE.NMBS." . $veh;
         $nodes[$i] = new DepartureArrival();
         $nodes[$i]->delay = $delay;
         $nodes[$i]->station = $stationNode;
         $nodes[$i]->time = $unixtime;
         $nodes[$i]->vehicle = $vehicle;
         $nodes[$i]->platform = new Platform();
         $nodes[$i]->platform->name = $platform;
         $nodes[$i]->platform->normal = $platformNormal;
         $nodes[$i]->left = $left;
         $hour_ = substr((string) $data->Journey[$i]["fpTime"], 0, 2);
         if ($hour_ != "23" && $hour == "23") {
             $hour_ = 24;
         }
         $minutes_ = substr((string) $data->Journey[$i]["fpTime"], 3, 2);
         $i++;
     }
     return array_merge($nodes);
     //array merge reindexes the array
 }
开发者ID:Tjoosten,项目名称:iRail,代码行数:88,代码来源:liveboard.php


注:本文中的tools::transformtime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。