當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Horde_Icalendar::findComponentByAttribute方法代碼示例

本文整理匯總了PHP中Horde_Icalendar::findComponentByAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Horde_Icalendar::findComponentByAttribute方法的具體用法?PHP Horde_Icalendar::findComponentByAttribute怎麽用?PHP Horde_Icalendar::findComponentByAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Horde_Icalendar的用法示例。


在下文中一共展示了Horde_Icalendar::findComponentByAttribute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _parseTZID

 /**
  * Groks the TZID and returns an offset in seconds from UTC for this
  * date and time.
  *
  * @param array $date   A date hash.
  * @param array $time   A time hash.
  * @param string $tzid  A timezone ID.
  *
  * @return integer  The offset from UTC in seconds for the provided
  *                  timezone and date/time.
  */
 protected function _parseTZID($date, $time, $tzid)
 {
     $vtimezone = $this->_container->findComponentByAttribute('vtimezone', 'TZID', $tzid);
     if (!$vtimezone) {
         return false;
     }
     $change_times = array();
     foreach ($vtimezone->getComponents() as $o) {
         $change_times = array_merge($change_times, $vtimezone->parseChild($o, $date['year']));
     }
     if (!$change_times) {
         return false;
     }
     usort($change_times, function ($a, $b) {
         if (!$a['end']) {
             if (!$b['end']) {
                 return $a['time'] - $b['time'];
             }
             return 1;
         }
         if (!$b['end']) {
             return -1;
         }
         return $a['end'] - $b['end'];
     });
     // Time is arbitrarily based on UTC for comparison.
     $t = @gmmktime($time['hour'], $time['minute'], $time['second'], $date['month'], $date['mday'], $date['year']);
     if ($t < $change_times[0]['time']) {
         return $change_times[0]['from'];
     }
     for ($i = 0, $n = count($change_times); $i < $n - 1; $i++) {
         // See Bug: 14153. Some timezone definitions may be such that a
         // transition will incorrectly match due to the way we parse the
         // 'end' times. There *may* be a more correct way to do this by
         // sorting the transitions/handling 'end' values differently.
         if ($t >= $change_times[$i]['time'] && $t < $change_times[$i + 1]['time'] && $this->_checkEndDate($t, $change_times[$i + 1])) {
             return $change_times[$i]['to'];
         }
     }
     if ($t >= $change_times[$n - 1]['time']) {
         return $change_times[$n - 1]['to'];
     }
     return false;
 }
開發者ID:kossamums,項目名稱:horde,代碼行數:55,代碼來源:Icalendar.php

示例2: _parseTZID

 /**
  * Groks the TZID and returns an offset in seconds from UTC for this
  * date and time.
  *
  * @param array $date   A date hash.
  * @param array $time   A time hash.
  * @param string $tzid  A timezone ID.
  *
  * @return integer  The offset from UTC in seconds for the provided
  *                  timezone and date/time.
  */
 protected function _parseTZID($date, $time, $tzid)
 {
     $vtimezone = $this->_container->findComponentByAttribute('vtimezone', 'TZID', $tzid);
     if (!$vtimezone) {
         return false;
     }
     $change_times = array();
     foreach ($vtimezone->getComponents() as $o) {
         $change_times = array_merge($change_times, $vtimezone->parseChild($o, $date['year']));
     }
     if (!$change_times) {
         return false;
     }
     usort($change_times, function ($a, $b) {
         if (!$a['end']) {
             if (!$b['end']) {
                 return $a['time'] - $b['time'];
             }
             return 1;
         }
         if (!$b['end']) {
             return -1;
         }
         return $a['end'] - $b['end'];
     });
     // Time is arbitrarily based on UTC for comparison.
     $t = @gmmktime($time['hour'], $time['minute'], $time['second'], $date['month'], $date['mday'], $date['year']);
     if ($t < $change_times[0]['time']) {
         return $change_times[0]['from'];
     }
     for ($i = 0, $n = count($change_times); $i < $n - 1; $i++) {
         if ($t >= $change_times[$i]['time'] && $t < $change_times[$i + 1]['time']) {
             return $change_times[$i]['to'];
         }
     }
     if ($t >= $change_times[$n - 1]['time']) {
         return $change_times[$n - 1]['to'];
     }
     return false;
 }
開發者ID:raz0rsdge,項目名稱:horde,代碼行數:51,代碼來源:Icalendar.php


注:本文中的Horde_Icalendar::findComponentByAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。