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


PHP Range::getDateXPeriodsAgo方法代碼示例

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


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

示例1: getLastDate

 public function getLastDate($date, $period, $comparedToXPeriods)
 {
     $pastDate = Range::getDateXPeriodsAgo(abs($comparedToXPeriods), $date, $period);
     if (empty($pastDate[0])) {
         throw new \Exception('Not possible to compare this date/period combination');
     }
     return $pastDate[0];
 }
開發者ID:dorelljames,項目名稱:piwik,代碼行數:8,代碼來源:Model.php

示例2: getOldestDateToProcessForNewSegment

 private function getOldestDateToProcessForNewSegment(Date $segmentCreatedTime)
 {
     if ($this->processNewSegmentsFrom == self::CREATION_TIME) {
         $this->logger->debug("process_new_segments_from set to segment_creation_time, oldest date to process is {time}", array('time' => $segmentCreatedTime));
         return $segmentCreatedTime;
     } elseif (preg_match("/^last([0-9]+)\$/", $this->processNewSegmentsFrom, $matches)) {
         $lastN = $matches[1];
         list($lastDate, $lastPeriod) = Range::getDateXPeriodsAgo($lastN, $segmentCreatedTime, 'day');
         $result = Date::factory($lastDate);
         $this->logger->debug("process_new_segments_from set to last{N}, oldest date to process is {time}", array('N' => $lastN, 'time' => $result));
         return $result;
     } else {
         $this->logger->debug("process_new_segments_from set to beginning_of_time or cannot recognize value");
         return null;
     }
 }
開發者ID:CaptainSharf,項目名稱:SSAD_Project,代碼行數:16,代碼來源:SegmentArchivingRequestUrlProvider.php

示例3: getOldestDateToProcessForNewSegment

 private function getOldestDateToProcessForNewSegment($idSite, $segment)
 {
     /**
      * @var Date $segmentCreatedTime
      * @var Date $segmentLastEditedTime
      */
     list($segmentCreatedTime, $segmentLastEditedTime) = $this->getCreatedTimeOfSegment($idSite, $segment);
     if ($this->processNewSegmentsFrom == self::CREATION_TIME) {
         $this->logger->debug("process_new_segments_from set to segment_creation_time, oldest date to process is {time}", array('time' => $segmentCreatedTime));
         return $segmentCreatedTime;
     } elseif ($this->processNewSegmentsFrom == self::LAST_EDIT_TIME) {
         $this->logger->debug("process_new_segments_from set to segment_last_edit_time, segment last edit time is {time}", array('time' => $segmentLastEditedTime));
         if ($segmentLastEditedTime === null || $segmentLastEditedTime->getTimestamp() < $segmentCreatedTime->getTimestamp()) {
             $this->logger->debug("segment last edit time is older than created time, using created time instead");
             $segmentLastEditedTime = $segmentCreatedTime;
         }
         return $segmentLastEditedTime;
     } elseif (preg_match("/^last([0-9]+)\$/", $this->processNewSegmentsFrom, $matches)) {
         $lastN = $matches[1];
         list($lastDate, $lastPeriod) = Range::getDateXPeriodsAgo($lastN, $segmentCreatedTime, 'day');
         $result = Date::factory($lastDate);
         $this->logger->debug("process_new_segments_from set to last{N}, oldest date to process is {time}", array('N' => $lastN, 'time' => $result));
         return $result;
     } else {
         $this->logger->debug("process_new_segments_from set to beginning_of_time or cannot recognize value");
         return null;
     }
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:28,代碼來源:SegmentArchivingRequestUrlProvider.php


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