本文整理匯總了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);
}
示例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;
}
示例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());
}