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


PHP Piwik_Date::today方法代码示例

本文整理汇总了PHP中Piwik_Date::today方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Date::today方法的具体用法?PHP Piwik_Date::today怎么用?PHP Piwik_Date::today使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik_Date的用法示例。


在下文中一共展示了Piwik_Date::today方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDayIsFinishedToday

 /**
  * today is NOT finished
  * @group Core
  * @group Period
  * @group Period_Day
  */
 public function testDayIsFinishedToday()
 {
     $period = new Piwik_Period_Day(Piwik_Date::today());
     $this->assertEquals(date("Y-m-d"), $period->toString());
     $this->assertEquals(array(), $period->getSubperiods());
     $this->assertEquals(0, $period->getNumberOfSubperiods());
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:13,代码来源:DayTest.php

示例2: isFinished

 public function isFinished()
 {
     $todayMidnight = Piwik_Date::today();
     if ($this->date->isEarlier($todayMidnight)) {
         return true;
     }
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:7,代码来源:Day.php

示例3: testToday

 /**
  * create today object check that timestamp is correct (midnight)
  * 
  * @group Core
  * @group Date
  */
 public function testToday()
 {
     $date = Piwik_Date::today();
     $this->assertEquals(strtotime(date("Y-m-d ") . " 00:00:00"), $date->getTimestamp());
     // test getDatetime()
     $this->assertEquals($date->getDatetime(), $date->getDateStartUTC());
     $date = $date->setTime('12:00:00');
     $this->assertEquals(date('Y-m-d') . ' 12:00:00', $date->getDatetime());
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:15,代码来源:DateTest.php

示例4: loadArchiveProperties

 /**
  * Inits the object
  */
 protected function loadArchiveProperties()
 {
     $this->idsite = $this->site->getId();
     $this->periodId = $this->period->getId();
     $this->dateStart = $this->period->getDateStart();
     $this->dateEnd = $this->period->getDateEnd();
     $this->tableArchiveNumeric = new Piwik_TablePartitioning_Monthly('archive_numeric');
     $this->tableArchiveNumeric->setIdSite($this->idsite);
     $this->tableArchiveNumeric->setTimestamp($this->dateStart->get());
     $this->tableArchiveBlob = new Piwik_TablePartitioning_Monthly('archive_blob');
     $this->tableArchiveBlob->setIdSite($this->idsite);
     $this->tableArchiveBlob->setTimestamp($this->dateStart->get());
     $this->strDateStart = $this->dateStart->toString();
     $this->strDateEnd = $this->dateEnd->toString();
     // if the current archive is a DAY and if it's today,
     // we set this maxTimestampArchive that defines the lifetime value of today's archive
     $this->maxTimestampArchive = 0;
     if ($this->period->getNumberOfSubperiods() == 0 && $this->period->toString() == date("Y-m-d")) {
         $this->maxTimestampArchive = time() - Zend_Registry::get('config')->General->time_before_today_archive_considered_outdated;
         $browserArchivingEnabled = Zend_Registry::get('config')->General->enable_browser_archiving_triggering;
         // see #1150; if new archives are not triggered from the browser,
         // we still want to try and return the latest archive available for today (rather than return nothing)
         if (!$browserArchivingEnabled) {
             $this->maxTimestampArchive = 0;
         }
     } else {
         if ($this->period->isFinished()) {
             $this->maxTimestampArchive = $this->period->getDateEnd()->setTime('00:00:00')->addDay(1)->getTimestamp();
         } else {
             $this->maxTimestampArchive = Piwik_Date::today()->getTimestamp();
         }
     }
     $db = Zend_Registry::get('db');
     $this->compressBlob = $db->hasBlobDataType();
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:38,代码来源:ArchiveProcessing.php

示例5: prepareArchive

 /**
  * Prepares the archive. Gets the idarchive from the ArchiveProcessing.
  *
  * This will possibly launch the archiving process if the archive was not available.
  * @return bool
  */
 public function prepareArchive()
 {
     $archiveJustProcessed = false;
     $periodString = $this->period->getLabel();
     $plugin = Piwik_ArchiveProcessing::getPluginBeingProcessed($this->getRequestedReport());
     $cacheKey = 'all';
     if ($periodString == 'range') {
         $cacheKey = $plugin;
     }
     if (!isset($this->alreadyChecked[$cacheKey])) {
         $this->isThereSomeVisits = false;
         $this->alreadyChecked[$cacheKey] = true;
         $dayString = $this->period->getPrettyString();
         $logMessage = sprintf("%s (%s), plugin %s", $periodString, $dayString, $plugin);
         // if the END of the period is BEFORE the website creation date
         // we already know there are no stats for this period
         // we add one day to make sure we don't miss the day of the website creation
         if ($this->period->getDateEnd()->addDay(2)->isEarlier($this->site->getCreationDate())) {
             Piwik::log(sprintf("Archive %s skipped, archive is before the website was created.", $logMessage));
             return;
         }
         // if the starting date is in the future we know there is no visit
         if ($this->period->getDateStart()->subDay(2)->isLater(Piwik_Date::today())) {
             Piwik::log(sprintf("Archive %s skipped, archive is after today.", $logMessage));
             return;
         }
         // we make sure the archive is available for the given date
         $periodLabel = $this->period->getLabel();
         $this->archiveProcessing = Piwik_ArchiveProcessing::factory($periodLabel);
         $this->archiveProcessing->setSite($this->site);
         $this->archiveProcessing->setPeriod($this->period);
         $this->archiveProcessing->setSegment($this->segment);
         $this->archiveProcessing->init();
         $this->archiveProcessing->setRequestedReport($this->getRequestedReport());
         $archivingDisabledArchiveNotProcessed = false;
         $idArchive = $this->archiveProcessing->loadArchive();
         if (empty($idArchive)) {
             if ($this->archiveProcessing->isArchivingDisabled()) {
                 $archivingDisabledArchiveNotProcessed = true;
                 $logMessage = sprintf("Archiving disabled, for %s", $logMessage);
             } else {
                 Piwik::log(sprintf("Processing %s, not archived yet...", $logMessage));
                 $archiveJustProcessed = true;
                 // Process the reports
                 $this->archiveProcessing->launchArchiving();
                 $idArchive = $this->archiveProcessing->getIdArchive();
                 $logMessage = sprintf("Processed %d, for %s", $idArchive, $logMessage);
             }
         } else {
             $logMessage = sprintf("Already processed, fetching idArchive = %d (idSite=%d), for %s", $idArchive, $this->site->getId(), $logMessage);
         }
         Piwik::log(sprintf("%s, Visits = %d", $logMessage, $this->archiveProcessing->getNumberOfVisits()));
         $this->isThereSomeVisits = !$archivingDisabledArchiveNotProcessed && $this->archiveProcessing->isThereSomeVisits();
         $this->idArchive = $idArchive;
     }
     return $archiveJustProcessed;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:63,代码来源:Single.php

示例6: prepareArchive

 /**
  * Prepares the archive. Gets the idarchive from the ArchiveProcessing.
  * 
  * This will possibly launch the archiving process if the archive was not available.
  */
 public function prepareArchive()
 {
     $archiveJustProcessed = false;
     $periodString = $this->period->getLabel();
     $plugin = Piwik_ArchiveProcessing::getPluginBeingProcessed($this->getRequestedReport());
     $cacheKey = 'all';
     if ($periodString == 'range') {
         $cacheKey = $plugin;
     }
     if (!isset($this->alreadyChecked[$cacheKey])) {
         $this->isThereSomeVisits = false;
         $this->alreadyChecked[$cacheKey] = true;
         $dayString = $this->period->getPrettyString();
         $logMessage = "Preparing archive: " . $periodString . "(" . $dayString . "), plugin {$plugin} ";
         // if the END of the period is BEFORE the website creation date
         // we already know there are no stats for this period
         // we add one day to make sure we don't miss the day of the website creation
         if ($this->period->getDateEnd()->addDay(2)->isEarlier($this->site->getCreationDate())) {
             Piwik::log("{$logMessage} skipped, archive is before the website was created.");
             return;
         }
         // if the starting date is in the future we know there is no visit
         if ($this->period->getDateStart()->subDay(2)->isLater(Piwik_Date::today())) {
             Piwik::log("{$logMessage} skipped, archive is after today.");
             return;
         }
         // we make sure the archive is available for the given date
         $periodLabel = $this->period->getLabel();
         $this->archiveProcessing = Piwik_ArchiveProcessing::factory($periodLabel);
         $this->archiveProcessing->setSite($this->site);
         $this->archiveProcessing->setPeriod($this->period);
         $this->archiveProcessing->setSegment($this->segment);
         $this->archiveProcessing->init();
         $this->archiveProcessing->setRequestedReport($this->getRequestedReport());
         $archivingDisabledArchiveNotProcessed = false;
         $idArchive = $this->archiveProcessing->loadArchive();
         if (empty($idArchive)) {
             if ($this->archiveProcessing->isArchivingDisabled()) {
                 $archivingDisabledArchiveNotProcessed = true;
                 $logMessage = "* ARCHIVING DISABLED, for {$logMessage}";
             } else {
                 Piwik::log("* PROCESSING {$logMessage}, not archived yet...");
                 $archiveJustProcessed = true;
                 // Process the reports
                 $this->archiveProcessing->launchArchiving();
                 $idArchive = $this->archiveProcessing->getIdArchive();
                 $logMessage = "PROCESSED: idArchive = " . $idArchive . ", for {$logMessage}";
             }
         } else {
             $logMessage = "* ALREADY PROCESSED, Fetching idArchive = {$idArchive} (idSite=" . $this->site->getId() . "), for {$logMessage}";
         }
         Piwik::log("{$logMessage}, Visits = " . $this->archiveProcessing->getNumberOfVisits());
         $this->isThereSomeVisits = !$archivingDisabledArchiveNotProcessed && $this->archiveProcessing->isThereSomeVisits();
         $this->idArchive = $idArchive;
     }
     return $archiveJustProcessed;
 }
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:62,代码来源:Single.php

示例7: loadArchiveProperties

 /**
  * Inits the object
  * 
  * @return void
  */
 protected function loadArchiveProperties()
 {
     $this->idsite = $this->site->getId();
     $this->periodId = $this->period->getId();
     $this->dateStart = $this->period->getDateStart();
     $this->dateEnd = $this->period->getDateEnd();
     $this->tableArchiveNumeric = new Piwik_TablePartitioning_Monthly('archive_numeric');
     $this->tableArchiveNumeric->setIdSite($this->idsite);
     $this->tableArchiveNumeric->setTimestamp($this->dateStart->get());
     $this->tableArchiveBlob = new Piwik_TablePartitioning_Monthly('archive_blob');
     $this->tableArchiveBlob->setIdSite($this->idsite);
     $this->tableArchiveBlob->setTimestamp($this->dateStart->get());
     $this->strDateStart = $this->dateStart->toString();
     $this->strDateEnd = $this->dateEnd->toString();
     // if the current archive is a DAY and if it's today,
     // we set this maxTimestampArchive that defines the lifetime value of today's archive
     $this->maxTimestampArchive = 0;
     if ($this->period->getNumberOfSubperiods() == 0 && $this->period->toString() == date("Y-m-d")) {
         $this->maxTimestampArchive = time() - Zend_Registry::get('config')->General->time_before_today_archive_considered_outdated;
     } else {
         if ($this->period->isFinished()) {
             $this->maxTimestampArchive = $this->period->getDateEnd()->setTime('00:00:00')->addDay(1)->getTimestamp();
         } else {
             $this->maxTimestampArchive = Piwik_Date::today()->getTimestamp();
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:32,代码来源:ArchiveProcessing.php

示例8: generate

 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 = Piwik_Date::today();
         }
         if ($lastOrPrevious == 'last') {
             $endDate = $defaultEndDate;
         } elseif ($lastOrPrevious == 'previous') {
             $endDate = $this->removePeriod($defaultEndDate, 1);
         }
         // last1 means only one result ; last2 means 2 results so we remove only 1 to the days/weeks/etc
         $lastN--;
         $lastN = abs($lastN);
         $lastN = $this->getMaxN($lastN);
         $startDate = $this->removePeriod($endDate, $lastN);
     } elseif (preg_match('/([0-9]{4}-[0-9]{1,2}-[0-9]{1,2}),([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})/', $this->strDate, $regs)) {
         $strDateStart = $regs[1];
         $strDateEnd = $regs[2];
         $startDate = Piwik_Date::factory($strDateStart);
         $endDate = Piwik_Date::factory($strDateEnd);
     } else {
         throw new Exception("The date '{$this->strDate}' is not a date range. Should have the following format: 'lastN' or 'previousN' or 'YYYY-MM-DD,YYYY-MM-DD'.");
     }
     $endSubperiod = Piwik_Period::factory($this->strPeriod, $endDate);
     $arrayPeriods = array();
     $arrayPeriods[] = $endSubperiod;
     while ($endDate->isLater($startDate)) {
         $endDate = $this->removePeriod($endDate, 1);
         $subPeriod = Piwik_Period::factory($this->strPeriod, $endDate);
         $arrayPeriods[] = $subPeriod;
     }
     $arrayPeriods = array_reverse($arrayPeriods);
     foreach ($arrayPeriods as $period) {
         $this->addSubperiod($period);
     }
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:45,代码来源:Range.php

示例9: testRangeYearLast1

 /**
  * @group Core
  * @group Period
  * @group Period_Range
  */
 public function testRangeYearLast1()
 {
     $range = new Piwik_Period_Range('year', 'last1');
     $currentYear = new Piwik_Period_Year(Piwik_Date::today());
     $this->assertEquals(1, $range->getNumberOfSubperiods());
     $this->assertEquals(array($currentYear->toString()), $range->toString());
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:12,代码来源:RangeTest.php

示例10: prepareArchive

 /**
  * Prepares the archive. Gets the idarchive from the ArchiveProcessing.
  * 
  * This will possibly launch the archiving process if the archive was not available.
  * 
  * @return void
  */
 public function prepareArchive()
 {
     $archiveJustProcessed = false;
     if (!$this->alreadyChecked) {
         $this->isThereSomeVisits = false;
         $this->alreadyChecked = true;
         // if the END of the period is BEFORE the website creation date
         // we already know there are no stats for this period
         // we add one day to make sure we don't miss the day of the website creation
         if ($this->period->getDateEnd()->addDay(2)->isEarlier($this->site->getCreationDate())) {
             return;
         }
         // if the starting date is in the future we know there is no visit
         if ($this->period->getDateStart()->subDay(1)->isLater(Piwik_Date::today())) {
             return;
         }
         // we make sure the archive is available for the given date
         $periodLabel = $this->period->getLabel();
         $archiveProcessing = Piwik_ArchiveProcessing::factory($periodLabel);
         $archiveProcessing->setSite($this->site);
         $archiveProcessing->setPeriod($this->period);
         $idArchive = $archiveProcessing->loadArchive();
         if ($idArchive === null) {
             $archiveJustProcessed = true;
             $archiveProcessing->launchArchiving();
             $idArchive = $archiveProcessing->getIdArchive();
         }
         $this->isThereSomeVisits = $archiveProcessing->isThereSomeVisits;
         $this->idArchive = $idArchive;
         $this->archiveProcessing = $archiveProcessing;
     }
     return $archiveJustProcessed;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:40,代码来源:Single.php

示例11: loadArchiveProperties

	/**
	 * Inits the object
	 */
	protected function loadArchiveProperties()
	{		
		$this->idsite = $this->site->getId();
		
		$this->periodId = $this->period->getId();
		
		$this->dateStart = $this->period->getDateStart();
		$this->dateEnd = $this->period->getDateEnd();
		
		$this->tableArchiveNumeric = new Piwik_TablePartitioning_Monthly('archive_numeric');
		$this->tableArchiveNumeric->setIdSite($this->idsite);
		$this->tableArchiveNumeric->setTimestamp($this->dateStart->get());
		$this->tableArchiveBlob = new Piwik_TablePartitioning_Monthly('archive_blob');
		$this->tableArchiveBlob->setIdSite($this->idsite);	
		$this->tableArchiveBlob->setTimestamp($this->dateStart->get());

		$this->strDateStart = $this->dateStart->toString();
		$this->strDateEnd = $this->dateEnd->toString();
		
		// if the current archive is a DAY and if it's today,
		// we set this maxTimestampArchive that defines the lifetime value of today's archive
		$this->maxTimestampArchive = 0;
		if( $this->period->getNumberOfSubperiods() == 0
			&& $this->period->toString() == date("Y-m-d")
			)
		{
			$this->maxTimestampArchive = time() - Zend_Registry::get('config')->General->time_before_today_archive_considered_outdated;
		}
		// either
		// - if the period we're looking for is finished, we look for a ts_archived that 
		//   is greater than the last day of the archive 
		// - if the period we're looking for is not finished, we look for a recent enough archive
		//   recent enough means maxTimestampArchive = 00:00:01 this morning
		else
		{
			if($this->period->isFinished())
			{
				$this->maxTimestampArchive = $this->period->getDateEnd()->setTime('00:00:00')->addDay(1)->getTimestamp();
			}
			else
			{
				$this->maxTimestampArchive = Piwik_Date::today()->getTimestamp();
			}
		}

		$db = Zend_Registry::get('db');
		$this->compressBlob = $db->hasBlobDataType();
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:51,代码来源:ArchiveProcessing.php

示例12: test_range_year_last1

 function test_range_year_last1()
 {
     $range = new Piwik_Period_Range('year', 'last1');
     $currentYear = new Piwik_Period_Year(Piwik_Date::today());
     $this->assertEqual($range->getNumberOfSubperiods(), 1);
     $this->assertEqual($range->toString(), array($currentYear->toString()));
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:7,代码来源:Period.test.php

示例13: testFactoryInvalid

 /**
  * @group Core
  * @group Period
  */
 public function testFactoryInvalid()
 {
     try {
         $period = Piwik_Period::factory('inValid', Piwik_Date::today());
     } catch (Exception $e) {
         return;
     }
     $this->fail('Expected Exception not raised');
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:13,代码来源:PeriodTest.php

示例14: test_today

 function test_today()
 {
     $date = Piwik_Date::today();
     $this->assertEqual(strtotime(date("Y-m-d ") . " 00:00:00"), $date->get());
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:5,代码来源:Date.test.php


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