当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::isEarlier方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:jniebuhr,项目名称:piwik,代码行数:13,代码来源:Month.php

示例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);
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:50,代码来源:Range.php

示例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;
 }
开发者ID:piwik,项目名称:piwik,代码行数:10,代码来源:Controller.php


注:本文中的Piwik\Date::isEarlier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。