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


PHP Horde_Date::after方法代碼示例

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


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

示例1: listTimeObjects

 /**
  *
  * @param Horde_Date $start  The start time of the period
  * @param Horde_Date $end   The end time of the period
  *
  * @return array of listTimeObjects arrays.
  */
 public function listTimeObjects(Horde_Date $start = null, Horde_Date $end = null)
 {
     global $conf, $prefs;
     // No need to continue if the forecast days are not in the current
     // range.
     $forecast_start = new Horde_Date(time());
     $forecast_end = clone $forecast_start;
     $forecast_end->mday += 7;
     if ($end->before($forecast_start) || $start->after($forecast_end)) {
         return array();
     }
     $weather = $this->_create();
     $lengths = $weather->getSupportedForecastLengths();
     try {
         $units = $weather->getUnits($weather->units);
         $forecast = $weather->getForecast($this->_location, max(array_keys($lengths)));
         $current = $weather->getCurrentConditions($this->_location);
     } catch (Horde_Service_Weather_Exception $e) {
         throw new Timeobjects_Exception($e);
     }
     $objects = array();
     foreach ($forecast as $data) {
         $day = $data->date;
         $day->hour = 0;
         $day->min = 0;
         $day->sec = 0;
         $day_end = clone $day;
         $day_end->mday++;
         $title = sprintf('%s %d°%s/%d°%s', $data->conditions, $data->high, $units['temp'], $data->low, $units['temp']);
         // Deterine what information we have to display.
         $pop = $data->precipitation_percent === false ? _("N/A") : $data->precipitation_percent . '%';
         if ($forecast->detail == Horde_Service_Weather::FORECAST_TYPE_STANDARD) {
             if ($data->humidity !== false && $data->wind_direction !== false) {
                 $description = sprintf(_("Conditions: %s\nHigh temperature: %d%s\nPrecipitation: %s\nHumidity: %d%%\nWinds: From the %s at %d%s"), _($data->conditions), $data->high, '°' . $units['temp'], $pop, $data->humidity, $data->wind_direction, $data->wind_speed, $units['wind']);
             } else {
                 $description = sprintf(_("Conditions: %s\nHigh temperature: %d%s\nPrecipitation: %s\n"), _($data->conditions), $data->high, '°' . $units['temp'], $pop);
             }
         } elseif ($forecast->detail == Horde_Service_Weather::FORECAST_TYPE_DETAILED) {
             // @TODO
             // No drivers support this yet. AccuWeather will, and possibly
             // wunderground if they accept my request.
         }
         $station = $weather->getStation();
         $body = sprintf(_("Location: %s"), $weather->getStation()->name);
         if (!empty($weather->getStation()->sunrise)) {
             $body .= sprintf(_("Sunrise: %s\nSunset: %s\n"), $weather->getStation()->sunrise, $weather->getStation()->sunset);
         }
         $body .= "\n" . $description;
         $objects[] = array('id' => $day->timestamp(), 'title' => $title, 'description' => $body, 'start' => $day->strftime('%Y-%m-%dT00:00:00'), 'end' => $day_end->strftime('%Y-%m-%dT00:00:00'), 'recurrence' => Horde_Date_Recurrence::RECUR_NONE, 'params' => array(), 'link' => new Horde_Url('#'), 'icon' => (string) Horde_Themes::img('weather/23x23/' . $data->icon));
         $day->mday++;
     }
     return $objects;
 }
開發者ID:horde,項目名稱:horde,代碼行數:60,代碼來源:Weather.php


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