本文整理汇总了PHP中Piwik\Date::isEarlier方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::isEarlier方法的具体用法?PHP Date::isEarlier怎么用?PHP Date::isEarlier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Date
的用法示例。
在下文中一共展示了Date::isEarlier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fillDayPeriods
/**
* Fills the periods from startDate to endDate with days
*
* @param Date $startDate
* @param Date $endDate
*/
private function fillDayPeriods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate) || $startDate == $endDate) {
$this->addSubperiod(new Day($startDate));
$startDate = $startDate->addDay(1);
}
}
示例2: processOptimalSubperiods
/**
* Determine which kind of period is best to use.
* See Range.test.php
*
* @param Date $startDate
* @param Date $endDate
*/
protected function processOptimalSubperiods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate) || $startDate == $endDate) {
$endOfPeriod = null;
$month = new Month($startDate);
$endOfMonth = $month->getDateEnd();
$startOfMonth = $month->getDateStart();
$year = new Year($startDate);
$endOfYear = $year->getDateEnd();
$startOfYear = $year->getDateStart();
if ($startDate == $startOfYear && ($endOfYear->isEarlier($endDate) || $endOfYear == $endDate || $endOfYear->isLater($this->today)) && !($endDate->isEarlier($this->today) && $this->today->toString('Y') == $endOfYear->toString('Y') && $this->today->compareYear($endOfYear) == 0)) {
$this->addSubperiod($year);
$endOfPeriod = $endOfYear;
} else {
if ($startDate == $startOfMonth && ($endOfMonth->isEarlier($endDate) || $endOfMonth == $endDate || $endOfMonth->isLater($this->today)) && !($endDate->isEarlier($this->today) && $this->today->toString('Y') == $endOfMonth->toString('Y') && $this->today->compareMonth($endOfMonth) == 0)) {
$this->addSubperiod($month);
$endOfPeriod = $endOfMonth;
} else {
// From start date,
// Process end of week
$week = new Week($startDate);
$startOfWeek = $week->getDateStart();
$endOfWeek = $week->getDateEnd();
$firstDayNextMonth = $startDate->addPeriod(2, 'month')->setDay(1);
$useMonthsNextIteration = $firstDayNextMonth->isEarlier($endDate);
if ($useMonthsNextIteration && $endOfWeek->isLater($endOfMonth)) {
$this->fillArraySubPeriods($startDate, $endOfMonth, 'day');
$endOfPeriod = $endOfMonth;
} elseif ($this->isEndOfWeekLaterThanEndDate($endDate, $endOfWeek) && ($endOfWeek->isEarlier($this->today) || $startOfWeek->toString() != $startDate->toString() || $endDate->isEarlier($this->today))) {
$this->fillArraySubPeriods($startDate, $endDate, 'day');
break 1;
} elseif ($startOfWeek->isEarlier($startDate) && $endOfWeek->isEarlier($this->today)) {
$this->fillArraySubPeriods($startDate, $endOfWeek, 'day');
$endOfPeriod = $endOfWeek;
} else {
$this->addSubperiod($week);
$endOfPeriod = $endOfWeek;
}
}
}
$startDate = $endOfPeriod->addDay(1);
}
}
示例3: getValidDate
private function getValidDate(Date $date, Date $minDate, Date $maxDate)
{
if ($date->isEarlier($minDate)) {
$date = $minDate;
}
if ($date->isLater($maxDate)) {
$date = $maxDate;
}
return $date;
}