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


PHP Range::setDefaultEndDate方法代碼示例

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


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

示例1: getTemperaturesEvolution

 public function getTemperaturesEvolution($date, $period)
 {
     $temperatures = array();
     $date = Date::factory('2013-10-10', 'UTC');
     $period = new Range($period, 'last30');
     $period->setDefaultEndDate($date);
     foreach ($period->getSubperiods() as $subPeriod) {
         if (self::$disableRandomness) {
             $server1 = 50;
             $server2 = 40;
         } else {
             $server1 = mt_rand(50, 90);
             $server2 = mt_rand(40, 110);
         }
         $value = array('server1' => $server1, 'server2' => $server2);
         $temperatures[$subPeriod->getLocalizedShortString()] = $value;
     }
     return DataTable::makeFromIndexedArray($temperatures);
 }
開發者ID:piwik,項目名稱:piwik,代碼行數:19,代碼來源:API.php

示例2: getRelativeToEndDate

 /**
  * Returns a date range string given a period type, end date and number of periods
  * the range spans over.
  *
  * @param string $period The sub period type, `'day'`, `'week'`, `'month'` and `'year'`.
  * @param int $lastN The number of periods of type `$period` that the result range should
  *                   span.
  * @param string $endDate The desired end date of the range.
  * @param Site $site The site whose timezone should be used.
  * @return string The date range string, eg, `'2012-01-02,2013-01-02'`.
  * @api
  */
 public static function getRelativeToEndDate($period, $lastN, $endDate, $site)
 {
     $last30Relative = new Range($period, $lastN, $site->getTimezone());
     $last30Relative->setDefaultEndDate(Date::factory($endDate));
     $date = $last30Relative->getDateStart()->toString() . "," . $last30Relative->getDateEnd()->toString();
     return $date;
 }
開發者ID:KiwiJuicer,項目名稱:handball-dachau,代碼行數:19,代碼來源:Range.php

示例3: testCustomRangePreviousN

 public function testCustomRangePreviousN()
 {
     $range = new Range('range', 'previous3');
     $range->setDefaultEndDate(Date::factory('2008-01-03'));
     $correct = array('2007-12-31', '2008-01-01', '2008-01-02');
     $this->assertEquals(count($correct), $range->getNumberOfSubperiods());
     $this->assertEquals($correct, $range->toString());
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:8,代碼來源:RangeTest.php


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