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


PHP Period::generate方法代碼示例

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


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

示例1: generate

 /**
  * Generates the subperiods (one for each month of the year)
  */
 protected function generate()
 {
     if ($this->subperiodsProcessed) {
         return;
     }
     parent::generate();
     $year = $this->date->toString("Y");
     for ($i = 1; $i <= 12; $i++) {
         $this->addSubperiod(new Month(Date::factory("{$year}-{$i}-01")));
     }
 }
開發者ID:jniebuhr,項目名稱:piwik,代碼行數:14,代碼來源:Year.php

示例2: generate

 /**
  * Generates the subperiods (one for each day in the month)
  */
 protected function generate()
 {
     if ($this->subperiodsProcessed) {
         return;
     }
     parent::generate();
     $date = $this->date;
     $startMonth = $date->setDay(1)->setTime('00:00:00');
     $endMonth = $startMonth->addPeriod(1, 'month')->setDay(1)->subDay(1);
     $this->processOptimalSubperiods($startMonth, $endMonth);
 }
開發者ID:jniebuhr,項目名稱:piwik,代碼行數:14,代碼來源:Month.php

示例3: generate

 /**
  * Generates the subperiods (one for each day in the month)
  */
 protected function generate()
 {
     if ($this->subperiodsProcessed) {
         return;
     }
     parent::generate();
     $date = $this->date;
     $startMonth = $date->setDay(1);
     $currentDay = clone $startMonth;
     while ($currentDay->compareMonth($startMonth) == 0) {
         $this->addSubperiod(new Day($currentDay));
         $currentDay = $currentDay->addDay(1);
     }
 }
開發者ID:KiwiJuicer,項目名稱:handball-dachau,代碼行數:17,代碼來源:Month.php

示例4: generate

 /**
  * Generates the subperiods - one for each day in the week
  */
 protected function generate()
 {
     if ($this->subperiodsProcessed) {
         return;
     }
     parent::generate();
     $date = $this->date;
     if ($date->toString('N') > 1) {
         $date = $date->subDay($date->toString('N') - 1);
     }
     $startWeek = $date;
     $currentDay = clone $startWeek;
     while ($currentDay->compareWeek($startWeek) == 0) {
         $this->addSubperiod(new Day($currentDay));
         $currentDay = $currentDay->addDay(1);
     }
 }
開發者ID:JoeHorn,項目名稱:piwik,代碼行數:20,代碼來源:Week.php

示例5: generate

 /**
  * Generates the subperiods
  *
  * @throws Exception
  */
 protected function generate()
 {
     if ($this->subperiodsProcessed) {
         return;
     }
     parent::generate();
     if (preg_match('/(last|previous)([0-9]*)/', $this->strDate, $regs)) {
         $lastN = $regs[2];
         $lastOrPrevious = $regs[1];
         if (!is_null($this->defaultEndDate)) {
             $defaultEndDate = $this->defaultEndDate;
         } else {
             $defaultEndDate = $this->today;
         }
         $period = $this->strPeriod;
         if ($period == 'range') {
             $period = 'day';
         }
         if ($lastOrPrevious == 'last') {
             $endDate = $defaultEndDate;
         } elseif ($lastOrPrevious == 'previous') {
             if ('month' == $period) {
                 $endDate = $defaultEndDate->subMonth(1);
             } else {
                 $endDate = $defaultEndDate->subPeriod(1, $period);
             }
         }
         $lastN = $this->getMaxN($lastN);
         // last1 means only one result ; last2 means 2 results so we remove only 1 to the days/weeks/etc
         $lastN--;
         $lastN = abs($lastN);
         $startDate = $endDate->addPeriod(-1 * $lastN, $period);
     } elseif ($dateRange = Range::parseDateRange($this->strDate)) {
         $strDateStart = $dateRange[1];
         $strDateEnd = $dateRange[2];
         $startDate = Date::factory($strDateStart);
         if ($strDateEnd == 'today') {
             $strDateEnd = 'now';
         } elseif ($strDateEnd == 'yesterday') {
             $strDateEnd = 'yesterdaySameTime';
         }
         // we set the timezone in the Date object only if the date is relative eg. 'today', 'yesterday', 'now'
         $timezone = null;
         if (strpos($strDateEnd, '-') === false) {
             $timezone = $this->timezone;
         }
         $endDate = Date::factory($strDateEnd, $timezone);
     } else {
         throw new Exception(Piwik::translate('General_ExceptionInvalidDateRange', array($this->strDate, ' \'lastN\', \'previousN\', \'YYYY-MM-DD,YYYY-MM-DD\'')));
     }
     if ($this->strPeriod != 'range') {
         $this->fillArraySubPeriods($startDate, $endDate, $this->strPeriod);
         return;
     }
     $this->processOptimalSubperiods($startDate, $endDate);
     // When period=range, we want End Date to be the actual specified end date,
     // rather than the end of the month / week / whatever is used for processing this range
     $this->endDate = $endDate;
 }
開發者ID:KiwiJuicer,項目名稱:handball-dachau,代碼行數:64,代碼來源:Range.php


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