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


PHP Toolbox::getTimestampTimeUnits方法代码示例

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


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

示例1: addDelayInDay

 /**
  * Add a delay of a starting hour in a specific day
  *
  * @param $calendars_id    id of the calendar
  * @param $day             day number
  * @param $begin_time      begin time
  * @param $delay           timestamp delay to add
  *
  * @return timestamp value
  **/
 static function addDelayInDay($calendars_id, $day, $begin_time, $delay)
 {
     global $DB;
     $sum = 0;
     // Do not check hour if day before the end day of after the begin day
     $query = "SELECT GREATEST(`begin`,'{$begin_time}') AS BEGIN,\n                       TIMEDIFF(`end`,GREATEST(`begin`,'{$begin_time}')) AS TDIFF\n                FROM `glpi_calendarsegments`\n                WHERE `calendars_id` = '{$calendars_id}'\n                     AND `day` = '{$day}'\n                     AND ('{$begin_time}' < `end`)\n                ORDER BY `begin`";
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 list($hour, $minute, $second) = explode(':', $data['TDIFF']);
                 $tstamp = $hour * HOUR_TIMESTAMP + $minute * MINUTE_TIMESTAMP + $second;
                 // Delay is completed
                 if ($delay <= $tstamp) {
                     list($begin_hour, $begin_minute, $begin_second) = explode(':', $data['BEGIN']);
                     $beginstamp = $begin_hour * HOUR_TIMESTAMP + $begin_minute * MINUTE_TIMESTAMP + $begin_second;
                     $endstamp = $beginstamp + $delay;
                     $units = Toolbox::getTimestampTimeUnits($endstamp);
                     return str_pad($units['hour'], 2, '0', STR_PAD_LEFT) . ':' . str_pad($units['minute'], 2, '0', STR_PAD_LEFT) . ':' . str_pad($units['second'], 2, '0', STR_PAD_LEFT);
                 } else {
                     $delay -= $tstamp;
                 }
             }
         }
     }
     return false;
 }
开发者ID:kipman,项目名称:glpi,代码行数:36,代码来源:calendarsegment.class.php

示例2: pdfForResource

 /**
  * Show for PDF an resources : tasks informations
  * 
  * @param $pdf object for the output
  * @param $ID of the resources
  */
 static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli)
 {
     global $DB;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_resources_haveRight("resources", "r")) {
         return false;
     }
     $query = "SELECT * \n               FROM `glpi_plugin_resources_tasks` \n               WHERE `plugin_resources_resources_id` = '{$ID}'\n               AND `is_deleted` ='0'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . self::getTypeName(2) . '</b>');
         $pdf->setColumnsSize(14, 14, 14, 14, 16, 14, 14);
         $pdf->displayTitle('<b><i>' . __('Name'), __('Type'), __('Comments'), __('Duration'), __('Planning'), __('Resource manager', 'resources'), __('Group') . '</i></b>');
         $i++;
         while ($j < $number) {
             $tID = $DB->result($result, $j, "id");
             $actiontime_ID = $DB->result($result, $j, "actiontime");
             $actiontime = '';
             $units = Toolbox::getTimestampTimeUnits($actiontime_ID);
             $hour = $units['hour'];
             $minute = $units['minute'];
             if ($hour) {
                 $actiontime = $hour . __('Hour', 'Hours', 2);
             }
             if ($minute || !$hour) {
                 $actiontime .= $minute . __('Minute', 'Minutes', 2);
             }
             $restrict = " `plugin_resources_tasks_id` = '" . $tID . "' ";
             $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
             if (!empty($plans)) {
                 foreach ($plans as $plan) {
                     $planification = Html::convDateTime($plan["begin"]) . "&nbsp;->&nbsp;" . Html::convDateTime($plan["end"]);
                 }
             } else {
                 $planification = __('None');
             }
             $users_id = $DB->result($result, $j, "users_id");
             $managers = Html::clean(getUserName($users_id));
             $name = $DB->result($result, $j, "name");
             $task_type = $DB->result($result, $j, "plugin_resources_tasktypes_id");
             $comment = $DB->result($result, $j, "comment");
             $groups_id = $DB->result($result, $j, "groups_id");
             $pdf->displayLine(Html::clean($name), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_tasktypes", $task_type)), $comment, $actiontime, Html::clean($planification), $managers, Html::clean(Dropdown::getDropdownName("glpi_groups", $groups_id)));
             $j++;
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:62,代码来源:task.class.php

示例3: timestampToString

 /**
  * Make a good string from the unix timestamp $sec
  *
  * @param $time         integer  timestamp
  * @param $display_sec  boolean  display seconds ? (true by default)
  * @param $use_days     boolean  use days for display ? (true by default)
  *
  * @return string
  **/
 static function timestampToString($time, $display_sec = true, $use_days = true)
 {
     $sign = '';
     if ($time < 0) {
         $sign = '- ';
         $time = abs($time);
     }
     $time = floor($time);
     // Force display seconds if time is null
     if ($time < MINUTE_TIMESTAMP) {
         $display_sec = true;
     }
     $units = Toolbox::getTimestampTimeUnits($time);
     if ($use_days) {
         if ($units['day'] > 0) {
             if ($display_sec) {
                 //TRANS: %1$s is the sign (-or empty), %2$d number of days, %3$d number of hours,
                 //       %4$d number of minutes, %5$d number of seconds
                 return sprintf(__('%1$s%2$d days %3$d hours %4$d minutes %5$d seconds'), $sign, $units['day'], $units['hour'], $units['minute'], $units['second']);
             }
             //TRANS:  %1$s is the sign (-or empty), %2$d number of days, %3$d number of hours,
             //        %4$d number of minutes
             return sprintf(__('%1$s%2$d days %3$d hours %4$d minutes'), $sign, $units['day'], $units['hour'], $units['minute']);
         }
     } else {
         if ($units['day'] > 0) {
             $units['hour'] += 24 * $units['day'];
         }
     }
     if ($units['hour'] > 0) {
         if ($display_sec) {
             //TRANS:  %1$s is the sign (-or empty), %2$d number of hours, %3$d number of minutes,
             //        %4$d number of seconds
             return sprintf(__('%1$s%2$d hours %3$d minutes %4$d seconds'), $sign, $units['hour'], $units['minute'], $units['second']);
         }
         //TRANS: %1$s is the sign (-or empty), %2$d number of hours, %3$d number of minutes
         return sprintf(__('%1$s%2$d hours %3$d minutes'), $sign, $units['hour'], $units['minute']);
     }
     if ($units['minute'] > 0) {
         if ($display_sec) {
             //TRANS:  %1$s is the sign (-or empty), %2$d number of minutes,  %3$d number of seconds
             return sprintf(__('%1$s%2$d minutes %3$d seconds'), $sign, $units['minute'], $units['second']);
         }
         //TRANS: %1$s is the sign (-or empty), %2$d number of minutes
         return sprintf(_n('%1$s%2$d minute', '%1$s%2$d minutes', $units['minute']), $sign, $units['minute']);
     }
     if ($display_sec) {
         //TRANS:  %1$s is the sign (-or empty), %2$d number of seconds
         return sprintf(_n('%1$s%2$s second', '%1$s%2$s seconds', $units['second']), $sign, $units['second']);
     }
     return '';
 }
开发者ID:OlivierLM,项目名称:glpi,代码行数:61,代码来源:html.class.php

示例4: timestampToStringShort

 /**
  * Make a short string from the unix timestamp $sec
  * derived from html::timestampToString
  *
  * @param $time         integer  timestamp
  *
  * @return string
  **/
 static function timestampToStringShort($time)
 {
     $sign = '';
     if ($time < 0) {
         $sign = '- ';
         $time = abs($time);
     }
     $time = floor($time);
     $units = Toolbox::getTimestampTimeUnits($time);
     // if more than 24 hours
     if ($units['day'] > 0) {
         $units['hour'] += 24 * $units['day'];
     }
     //TRANS:  %1$s is the sign (-or empty), %2$d number of hours, %3$d number of minutes,
     //        %4$d number of seconds
     return sprintf('%1$s%2$02d:%3$02d:%4$02d', $sign, $units['hour'], $units['minute'], $units['second']);
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:25,代码来源:thread.class.php


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