本文整理汇总了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());
}