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


PHP Date::subtractSpan方法代码示例

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


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

示例1: MAX_getDatesByPeriodLimitStart

function MAX_getDatesByPeriodLimitStart($period, $limit, $start)
{
    $begin = $limit + $start - 1;
    $end = $start;
    switch ($period) {
        case 'daily':
            $dayBegin = new Date();
            $dayBegin->subtractSpan(new Date_Span("{$begin}, 0, 0, 0"));
            $dayEnd = new Date();
            $dayBegin->subtractSpan(new Date_Span("{$end}, 0, 0, 0"));
            break;
        case 'weekly':
            $dayBegin = new Date(Date_Calc::prevDay());
            $dayEnd = new Date(Date_Calc::prevDay());
            break;
        case 'monthly':
            $dayBegin = new Date();
            $dayBegin->subtractSpan(new Date_Span('6, 0, 0, 0'));
            $dayEnd = new Date();
            break;
        case 'allstats':
        default:
            $dayBegin = null;
            $dayEnd = null;
    }
    $aDates = array();
    $aDates['day_begin'] = is_object($dayBegin) ? $dayBegin->format('%Y-%m-%d') : '';
    $aDates['day_end'] = is_object($dayEnd) ? $dayEnd->format('%Y-%m-%d') : '';
    return $aDates;
}
开发者ID:Jaree,项目名称:revive-adserver,代码行数:30,代码来源:stats.php

示例2: Date

 function __construct()
 {
     // Check auto-maintenance settings
     $aConf = $GLOBALS['_MAX']['CONF'];
     $this->isAutoMaintenanceEnabled = !empty($aConf['maintenance']['autoMaintenance']);
     // Get time 1 hour ago
     $oServiceLocator =& OA_ServiceLocator::instance();
     $oNow = $oServiceLocator->get('now');
     if ($oNow) {
         $oOneHourAgo = new Date($oNow);
     } else {
         $oOneHourAgo = new Date();
     }
     $oOneHourAgo->subtractSpan(new Date_Span('0-1-0-0'));
     // Get last runs
     $oLastCronRun = OX_Maintenance::getLastScheduledRun();
     $oLastRun = OX_Maintenance::getLastRun();
     // Reset minutes and seconds
     if (isset($oLastCronRun)) {
         $oLastCronRun->setMinute(0);
         $oLastCronRun->setSecond(0);
     }
     if (isset($oLastRun)) {
         $oLastRun->setMinute(0);
         $oLastRun->setSecond(0);
     }
     // Check if any kind of maintenance was run
     if (isset($oLastCronRun) && !$oOneHourAgo->after($oLastCronRun)) {
         $this->isScheduledMaintenanceRunning = true;
     } elseif (isset($oLastRun) && !$oOneHourAgo->after($oLastRun)) {
         $this->isAutoMaintenanceRunning = true;
     }
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:33,代码来源:Status.php

示例3: getStats

 function getStats()
 {
     // Set time zone to local
     OA_setTimeZoneLocal();
     $oEnd = new Date();
     $oEnd->setHour(0);
     $oEnd->setMinute(0);
     $oEnd->setSecond(0);
     $oEnd->toUTC();
     $oStart = new Date($oEnd);
     $oStart->subtractSpan(new Date_Span('7-0-0-0'));
     $oStart->toUTC();
     $doDsah = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDsah->selectAdd();
     $doDsah->selectAdd("DATE_FORMAT(date_time, '%Y-%m-%d') AS day");
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.impressions) AS total_impressions');
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.clicks) AS total_clicks');
     $doDsah->whereAdd("date_time >= '" . $doDsah->escape($oStart->format('%Y-%m-%d %H:%M:%S')) . "'");
     $doDsah->whereAdd("date_time < '" . $doDsah->escape($oEnd->format('%Y-%m-%d %H:%M:%S')) . "'");
     if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $doBanners = OA_Dal::factoryDO('banners');
         $doCampaigns = OA_Dal::factoryDO('campaigns');
         $doClients = OA_Dal::factoryDO('clients');
         $doClients->agencyid = OA_Permission::getEntityId();
         $doCampaigns->joinAdd($doClients);
         $doBanners->joinAdd($doCampaigns);
         $doBanners->selectAdd();
         $doBanners->selectAdd("bannerid");
         $doBanners->find();
         $ad_ids = array();
         while ($doBanners->fetch()) {
             $ad_ids[] = $doBanners->bannerid;
         }
         if (empty($ad_ids)) {
             return array();
         }
         $doDsah->whereAdd("ad_id IN (" . implode(",", $ad_ids) . ")");
     }
     $doDsah->groupBy('day');
     $doDsah->orderBy('day');
     $doDsah->find();
     $aStats = array();
     while ($doDsah->fetch()) {
         $row = $doDsah->toArray();
         $aStats[0][date('D', strtotime($row['day']))] = $row['total_impressions'];
         $aStats[1][date('D', strtotime($row['day']))] = $row['total_clicks'];
     }
     return $aStats;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:49,代码来源:GraphOAP.php

示例4: getLinks

 public function getLinks()
 {
     $oDate = new Date($this->oStart);
     $oNow = new Date();
     $aLinks = array();
     $baseUrl = parent::getUrl(false);
     $date = $oDate->format('%Y-%m');
     $aLinks['up'] = array('label' => $date, 'url' => $this->appendToUrl($baseUrl, 'month=' . $date));
     $oDate->subtractSpan(new Date_Span('1-0-0-0'));
     $date = $oDate->format('%Y-%m-%d');
     $aLinks['prev'] = array('label' => '< ' . $date, 'url' => $this->appendToUrl($baseUrl, 'day=' . $date));
     $oDate->addSpan(new Date_Span('2-0-0-0'));
     $date = $oDate->format('%Y-%m-%d');
     $aLinks['next'] = array('label' => $date . ' >');
     if ($oNow->after($oDate)) {
         $aLinks['next']['url'] = $this->appendToUrl($baseUrl, 'day=' . $date);
     }
     return $aLinks;
 }
开发者ID:SamWinchester,项目名称:revive-adserver,代码行数:19,代码来源:Hourly.php

示例5: Date

 function _subtractDays($base_date, $days)
 {
     $modified_date = new Date($base_date);
     $span = new Date_Span((string) $days, '%D');
     $modified_date->subtractSpan($span);
     return $modified_date;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:7,代码来源:DateRange.php

示例6: Date

 /**
  * A method to generate data for testing.
  *
  * @access private
  */
 function _generateStatsOne()
 {
     $oDate = new Date();
     $oDate->setHour(23);
     $oDate->setMinute(59);
     $oDate->setSecond(59);
     $oDate->addSpan(new Date_Span('4-0-0-0'));
     $expiryDate1 = $oDate->getDate(DATE_FORMAT_ISO);
     $oDate->addSpan(new Date_Span('4-0-0-0'));
     $expiryDate2 = $oDate->getDate(DATE_FORMAT_ISO);
     $oDate->subtractSpan(new Date_Span('2-0-0-0'));
     $expiryDateLessTwoDays = $oDate->getDate(DATE_FORMAT_ISO);
     $doAcls = OA_Dal::factoryDO('acls');
     $doBanners = OA_Dal::factoryDO('banners');
     // default values
     $doBanners->status = OA_ENTITY_STATUS_RUNNING;
     $doBanners->contenttype = 'gif';
     $doBanners->pluginversion = 0;
     $doBanners->storagetype = 'sql';
     $doBanners->filename = '468x60_4.gif';
     $doBanners->imageurl = '';
     $doBanners->htmltemplate = '';
     $doBanners->htmlcache = '';
     $doBanners->width = 468;
     $doBanners->height = 60;
     $doBanners->weight = 1;
     $doBanners->seq = 0;
     $doBanners->target = '';
     $doBanners->url = 'http://www.example.com';
     $doBanners->alt = 'Campaign Alt Text';
     $doBanners->statustext = '';
     $doBanners->bannertext = '';
     $doBanners->description = '';
     $doBanners->adserver = '';
     $doBanners->block = 0;
     $doBanners->capping = 0;
     $doBanners->session_capping = 0;
     $doBanners->compiledlimitation = '';
     $doBanners->prepend = '';
     $doBanners->append = '';
     $doBanners->bannertype = 0;
     $doBanners->alt_filename = '';
     $doBanners->alt_imageurl = '';
     $doBanners->alt_contenttype = '';
     $clientId = DataGenerator::generateOne('clients', true);
     // Add 3 campaigns - haha!
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'Test Campaign 1';
     $doCampaigns->clientid = $clientId;
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 400;
     $doCampaigns->conversions = 0;
     $doCampaigns->expire_time = $expiryDate1;
     $doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
     $doCampaigns->priority = '3';
     $doCampaigns->weight = 1;
     $doCampaigns->target_impression = 0;
     $doCampaigns->anonymous = 'f';
     $doCampaigns->updated = $oDate->format('%Y-%m-%d %H:%M:%S');
     $idCampaign1 = DataGenerator::generateOne($doCampaigns, true);
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'Test Campaign 2';
     $doCampaigns->clientid = $clientId;
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 400;
     $doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
     $doCampaigns->priority = '2';
     $doCampaigns->weight = 1;
     $doCampaigns->target_impression = 0;
     $doCampaigns->anonymous = 'f';
     $doCampaigns->updated = $oDate->format('%Y-%m-%d %H:%M:%S');
     $idCampaign2 = DataGenerator::generateOne($doCampaigns, true);
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'Test Campaign 3';
     $doCampaigns->clientid = $clientId;
     $doCampaigns->views = 500;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 0;
     $doCampaigns->expire = $expiryDate2;
     $doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
     $doCampaigns->priority = '3';
     $doCampaigns->weight = 1;
     $doCampaigns->target_impression = 0;
     $doCampaigns->anonymous = 'f';
     $doCampaigns->updated = $oDate->format('%Y-%m-%d %H:%M:%S');
     $idCampaign3 = DataGenerator::generateOne($doCampaigns, true);
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'Test Campaign 4';
     $doCampaigns->clientid = $clientId;
     $doCampaigns->views = 500;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 401;
     $doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
     $doCampaigns->priority = '4';
//.........这里部分代码省略.........
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:101,代码来源:Priority_getCampaigns.dal.test.php

示例7: Date

 /**
  * Build the internal arrays that contain data about the calculated holidays
  *
  * @access   protected
  * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  * @throws   object PEAR_ErrorStack
  */
 function _buildHolidays()
 {
     /**
      * New Year's Day
      */
     $this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
     /**
      * Epiphanias
      */
     $this->_addHoliday('epiphany', $this->_year . '-01-06', 'Epiphany');
     /**
      * Easter Sunday
      */
     $easterDate = Date_Holidays_Driver_Sweden::calcEaster($this->_year);
     $this->_addHoliday('easter', $easterDate, 'Easter Sunday');
     /**
      * Good Friday / Black Friday
      */
     $goodFridayDate = new Date($easterDate);
     $goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
     $this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
     /**
      * Easter Monday
      */
     $this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
     /**
      * May Day
      */
     $this->_addHoliday('mayDay', $this->_year . '-05-01', 'May Day');
     /**
      * Pentecost (determines Whit Monday, Ascension Day and Feast of Corpus Christi)
      */
     $pentecostDate = new Date($easterDate);
     $pentecostDate->addSpan(new Date_Span('49, 0, 0, 0'));
     $this->_addHoliday('pentecost', $pentecostDate, 'Pentecost');
     /**
      * Ascension Day
      */
     $ascensionDayDate = new Date($pentecostDate);
     $ascensionDayDate->subtractSpan(new Date_Span('10, 0, 0, 0'));
     $this->_addHoliday('ascensionDay', $ascensionDayDate, 'Ascension Day');
     /**
      * Swedish National Day and the Swedish Flag's Day
      */
     $this->_addHoliday('swedenNationalDay', $this->_year . '-06-06', 'Swedish National Day and the Swedish Flag\'s Day');
     /**
      * Midsummer
      * Saturday past 20th, June
      */
     $juneDate = new Date($this->_year . '-06-20');
     $dayOfWeek = $juneDate->getDayOfWeek();
     $juneDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0', 6 - $dayOfWeek)));
     $midSummerDate = $juneDate;
     $this->_addHoliday('midSummer', $midSummerDate, 'Midsummer Day');
     /**
      * Midsummer Eve
      * Day before Midsummer.
      */
     $this->_addHoliday('midSummerEve', $midSummerDate->getPrevDay(), 'Midsummer Eve');
     /**
      * All Saints' Day
      */
     $saintspanDate = new Date($this->_year . '-10-31');
     $dayOfWeek = $saintspanDate->getDayOfWeek();
     $saintspanDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0', 6 - $dayOfWeek)));
     $allSaintsDate = $saintspanDate;
     $this->_addHoliday('allSaintsDay', $allSaintsDate, 'All Saints\' Day');
     /**
      * Christmas Eve
      */
     $this->_addHoliday('xmasEve', $this->_year . '-12-24', 'Christmas Eve');
     /**
      * Christmas day
      */
     $this->_addHoliday('xmasDay', $this->_year . '-12-25', 'Christmas Day');
     /**
      * Boxing day
      */
     $this->_addHoliday('boxingDay', $this->_year . '-12-26', 'Boxing Day');
     /**
      * New Year's Eve
      */
     $this->_addHoliday('newYearsEve', $this->_year . '-12-31', 'New Year\'s Eve');
     if (Date_Holidays::errorsOccurred()) {
         return Date_Holidays::getErrorStack();
     }
     return true;
 }
开发者ID:slawekmikula,项目名称:dotproject,代码行数:95,代码来源:Sweden.php

示例8: Date

 /**
  * A method to test the sending of emails from the
  * manageCampaigns() method - tests the sending of
  * the "campaign activated" emails.
  */
 function testManageCampaignsEmailsPlacementActivated()
 {
     // Set now as 1 week before
     $oDateNow = new Date();
     $oDateNow->subtractSpan(new Date_Span('7-0-0-0'));
     $oServiceLocator =& OA_ServiceLocator::instance();
     $oServiceLocator->register('now', $oDateNow);
     // Create the required accounts & set the various ID values
     $aValues = $this->_createAccounts();
     $managerAgencyId = $aValues['managerAgency'];
     // Prepare a single placement that is inactive, and has an old
     // activation date (so that it will need to be activated)
     $aData = array('agencyid' => $managerAgencyId, 'contact' => 'Test Placement Activated Contact', 'email' => 'postmaster@placement.activated', 'reportdeactivate' => 't');
     $advertiserId = $this->_insertAdvertiser($aData);
     $oDate = new Date();
     $oDateStart = new Date();
     $oDateStart->copy($oDate);
     $oDateStart->subtractSeconds(SECONDS_PER_HOUR + 1);
     $aData = array('clientid' => $advertiserId, 'status' => OA_ENTITY_STATUS_AWAITING, 'activate_time' => $oDateStart->format('%Y-%m-%d 00:00:00'));
     $campaignId = $this->_insertPlacement($aData);
     // Reset now
     $oServiceLocator->remove('now');
     $aData = array('campaignid' => $campaignId);
     $adId = $this->_insertAd($aData);
     // Create an instance of the mocked OA_Email class, and set
     // expectations on how the class' methods should be called
     // based on the above
     Mock::generate('OA_Email');
     $oEmailMock = new MockOA_Email($this);
     $oEmailMock->expectOnce('sendCampaignActivatedDeactivatedEmail', array("{$campaignId}"));
     // Register the mocked OA_Email class in the service locator
     $oServiceLocator =& OA_ServiceLocator::instance();
     $oServiceLocator->register('OA_Email', $oEmailMock);
     // Run the manageCampaigns() method and ensure that the correct
     // calls to OA_Email were made
     $oDate = new Date();
     $oFactory = new OX_Dal_Maintenance_Statistics_Factory();
     $oDalMaintenanceStatistics = $oFactory->factory();
     $report = $oDalMaintenanceStatistics->manageCampaigns($oDate);
     $oEmailMock->tally();
     // Clean up
     DataGenerator::cleanUp();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:48,代码来源:Statistics_manageCampaigns.dal.test.php

示例9: Date

 /**
  * Build the internal arrays that contain data about the calculated holidays
  *
  * @access   protected
  * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  * @throws   object PEAR_ErrorStack
  */
 function _buildHolidays()
 {
     /**
      * New Year's Day
      */
     $this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
     /**
      * Easter Sunday
      */
     $easterDate = Date_Holidays_Driver_Norway::calcEaster($this->_year);
     $this->_addHoliday('easter', $easterDate, 'Easter Sunday');
     /**
      * Good Friday / Black Friday
      */
     $goodFridayDate = new Date($easterDate);
     $goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
     $this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
     /**
      * Easter Monday
      */
     $this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
     /**
      * May Day
      */
     $this->_addHoliday('mayDay', $this->_year . '-05-01', 'May Day');
     /**
      * Pentecost (determines Whit Monday, Ascension Day and Feast of Corpus Christi)
      */
     $pentecostDate = new Date($easterDate);
     $pentecostDate->addSpan(new Date_Span('49, 0, 0, 0'));
     $this->_addHoliday('pentecost', $pentecostDate, 'Pentecost');
     /**
      * Ascension Day
      */
     $ascensionDayDate = new Date($pentecostDate);
     $ascensionDayDate->subtractSpan(new Date_Span('10, 0, 0, 0'));
     $this->_addHoliday('ascensionDay', $ascensionDayDate, 'Ascension Day');
     /**
      * Norwegian National Day
      */
     $this->_addHoliday('norwayNationalDay', $this->_year . '-05-17', 'Norwegian National Day');
     /**
      * Christmas Eve
      */
     $this->_addHoliday('xmasEve', $this->_year . '-12-24', 'Christmas Eve');
     /**
      * Christmas day
      */
     $this->_addHoliday('xmasDay', $this->_year . '-12-25', 'Christmas Day');
     /**
      * Boxing day
      */
     $this->_addHoliday('boxingDay', $this->_year . '-12-26', 'Boxing Day');
     /**
      * New Year's Eve
      */
     $this->_addHoliday('newYearsEve', $this->_year . '-12-31', 'New Year\'s Eve');
     if (Date_Holidays::errorsOccurred()) {
         return Date_Holidays::getErrorStack();
     }
     return true;
 }
开发者ID:slawekmikula,项目名称:dotproject,代码行数:69,代码来源:Norway.php

示例10: getZonesPerformanceStatistics

 /**
  * This method returns performance statistics for a given zones.
  *
  * @access public
  *
  * @param array $aZonesIds array of IDs of the zones to view statistics
  * @param int $campaignId The ID of the campaing for which zones statistic are calculated (if null, then global zone statistic are calculated)
  * @param PEAR::Date $oStartDate The date from which to get statistics (inclusive)
  * @param PEAR::Date $oEndDate The date to which to get statistics (inclusive)
  * @param int $impressionsThreshold  Minimum number of impressions needed to calculate performance statistics (eCPM, CR, CTR)
  * @param int $daysIntervalThreshold  Minimum period of time (in days) needed to calculate performance statistics (eCPM, CR, CTR)
  * @return array 
  *   <ul>
  *   <li><b>zone_id integer</b> key The ID of the zone
  *   <li><b>array<b> with statistics
  *      <ul>
  *      <li><b>CTR decimal</b> CTR - Click Through Rate
  *      <li><b>eCPM decimal</b> eCPM - effective cost per mille
  *      <li><b>CR decimal</b> CR - Conversion Rate
  *      </ul>
  *   </li>
  *   </ul>
  */
 function getZonesPerformanceStatistics($aZonesIds, $campaignId = null, $oStartDate = null, $oEndDate = null, $impressionsThreshold = null, $daysIntervalThreshold = null)
 {
     if (!is_array($aZonesIds) || count($aZonesIds) == 0) {
         return array();
     }
     if (is_null($oEndDate)) {
         $oEndDate = new Date();
     }
     if (is_null($oStartDate)) {
         $oStartDate = new Date($oEndDate);
         $oStartDate->subtractSpan(new Date_Span("30, 0, 0, 0"));
         // Set start date to 30 days before end date is start date is null
     }
     // Initial setting of result array
     $aZonesStatistics = array();
     foreach ($aZonesIds as $zoneId) {
         $aZonesStatistics[$zoneId] = array('CTR' => null, 'eCPM' => null, 'CR' => null);
     }
     // If time span for given dates is greater that daysIntervalThreshold there isn't any statistics to calculate
     if ($this->_checkDaysIntervalThreshold($oStartDate, $oEndDate, $daysIntervalThreshold) == false) {
         return $aZonesStatistics;
     }
     // Query DB for all statistics and catch errors if any
     $rsZonesConversionRateStatistics = $this->getZonesConversionRateStatistics($aZonesIds, $oStartDate, $oEndDate, $campaignId, $impressionsThreshold, $daysIntervalThreshold);
     if (PEAR::isError($rsZonesConversionRateStatistics)) {
         return $rsZonesConversionRateStatistics;
     }
     $rsZonesEcpmStatistics = $this->getZonesEcpmStatistics($aZonesIds, $oStartDate, $oEndDate, $campaignId, $impressionsThreshold, $daysIntervalThreshold);
     if (PEAR::isError($rsZonesEcpmStatistics)) {
         return $rsZonesEcpmStatistics;
     }
     $rsZonesCtrStatistics = $this->getZonesCtrStatistics($aZonesIds, $oStartDate, $oEndDate, $campaignId, $impressionsThreshold, $daysIntervalThreshold);
     if (PEAR::isError($rsZonesCtrStatistics)) {
         return $rsZonesCtrStatistics;
     }
     // fill result array with statistics
     $aZonesEcpmStatistics = $rsZonesEcpmStatistics->getAll();
     foreach ($aZonesEcpmStatistics as $aZoneStatistics) {
         if (!is_null($aZoneStatistics['total_revenue']) && !is_null($aZoneStatistics['impressions']) && $aZoneStatistics['impressions'] != 0) {
             $aZonesStatistics[$aZoneStatistics['zone_id']]['eCPM'] = $aZoneStatistics['total_revenue'] * 1000 / $aZoneStatistics['impressions'];
         }
     }
     $aZonesConversionRateStatistics = $rsZonesConversionRateStatistics->getAll();
     foreach ($aZonesConversionRateStatistics as $aZoneStatistics) {
         if (!is_null($aZoneStatistics['conversions']) && !is_null($aZoneStatistics['impressions']) && $aZoneStatistics['impressions'] != 0) {
             $aZonesStatistics[$aZoneStatistics['zone_id']]['CR'] = $aZoneStatistics['conversions'] / $aZoneStatistics['impressions'];
         }
     }
     $aZonesCtrStatistics = $rsZonesCtrStatistics->getAll();
     foreach ($aZonesCtrStatistics as $aZoneStatistics) {
         if (!is_null($aZoneStatistics['clicks']) && !is_null($aZoneStatistics['impressions']) && $aZoneStatistics['impressions'] != 0) {
             $aZonesStatistics[$aZoneStatistics['zone_id']]['CTR'] = $aZoneStatistics['clicks'] / $aZoneStatistics['impressions'];
         }
     }
     return $aZonesStatistics;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:79,代码来源:Zone.php

示例11: Date

 /**
  * Prune all entries where the ad_id is for a banner in a High Priority Campaign where:
  * The campaign does not have any booked lifetime target values AND the capaign has an end date AND the end date has been passed AND the campaign is not active.
  *
  */
 function testpruneDataSummaryAdZoneAssocInactiveExpired()
 {
     $oToday = new Date();
     $oToday->setHour(23);
     $oToday->setMinute(59);
     $oToday->setSecond(59);
     $oExpire = new Date($oToday);
     $oExpire->subtractSpan(new Date_Span('10-0-0-0'));
     $today = $oToday->getDate(DATE_FORMAT_ISO);
     $expire = $oExpire->getDate(DATE_FORMAT_ISO);
     $oDal = new OA_Maintenance_Pruning();
     $doDSAZA = OA_Dal::factoryDO('data_summary_ad_zone_assoc');
     // generate 2 summary ad_zone records for an active campaign ad_id
     $doDSAZA->ad_id = $this->idBanner1;
     $aIds = DataGenerator::generate($doDSAZA, 2);
     // generate 7 summary ad_zone records for an inactive campaign ad_id
     $doDSAZA->ad_id = $this->idBanner2;
     $aIds = DataGenerator::generate($doDSAZA, 7);
     // make sure 9 rows in table
     $this->assertEqual($this->_countRowsInDSAZA(), 9);
     // ad_id 1 => campaignid 1 => active, high priority, not expired
     $doCampaigns = OA_Dal::staticGetDO('campaigns', $this->idCampaign1);
     $doCampaigns->priority = 5;
     $doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
     $doCampaigns->target_impression = 0;
     $doCampaigns->target_click = 0;
     $doCampaigns->target_conversion = 0;
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 0;
     $doCampaigns->update();
     // ad_id 2 => campaignid 2 => not active, high priority, expired
     $doCampaigns = OA_Dal::staticGetDO('campaigns', $this->idCampaign2);
     $doCampaigns->priority = 5;
     $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
     $doCampaigns->target_impression = 0;
     $doCampaigns->target_click = 0;
     $doCampaigns->target_conversion = 0;
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 0;
     $doCampaigns->expire_time = $expire;
     $doCampaigns->update();
     $result = $oDal->_pruneDataSummaryAdZoneAssocInactiveExpired();
     // 7 records were deleted
     $this->assertEqual($result, 7);
     // 2 records remain
     $this->assertEqual($this->_countRowsInDSAZA(), 2);
     // ad_id 1 => campaignid 1 => not active, override (low priority)
     $doCampaigns = OA_Dal::staticGetDO('campaigns', $this->idCampaign1);
     $doCampaigns->priority = -1;
     $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
     $doCampaigns->target_impression = 0;
     $doCampaigns->target_click = 0;
     $doCampaigns->target_conversion = 0;
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 0;
     $doCampaigns->expire_time = $expire;
     $doCampaigns->update();
     $result = $oDal->_pruneDataSummaryAdZoneAssocInactiveExpired();
     // 0 records were deleted
     $this->assertEqual($result, 0);
     // 2 records remain
     $this->assertEqual($this->_countRowsInDSAZA(), 2);
     // ad_id 1 => campaignid 1 => not active, high priority, not expired
     $doCampaigns = OA_Dal::staticGetDO('campaigns', $this->idCampaign1);
     $doCampaigns->priority = 5;
     $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
     $doCampaigns->target_impression = 0;
     $doCampaigns->target_click = 0;
     $doCampaigns->target_conversion = 0;
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 0;
     $doCampaigns->expire_time = OX_DATAOBJECT_NULL;
     $doCampaigns->update();
     $result = $oDal->_pruneDataSummaryAdZoneAssocInactiveExpired();
     // 0 records were deleted
     $this->assertEqual($result, 0);
     // 2 records remain
     $this->assertEqual($this->_countRowsInDSAZA(), 2);
     // ad_id 1 => campaignid 1 => not active, high priority, expired
     $doCampaigns = OA_Dal::staticGetDO('campaigns', $this->idCampaign1);
     $doCampaigns->priority = 5;
     $doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
     $doCampaigns->target_impression = 0;
     $doCampaigns->target_click = 0;
     $doCampaigns->target_conversion = 0;
     $doCampaigns->views = 0;
     $doCampaigns->clicks = 0;
     $doCampaigns->conversions = 0;
     $doCampaigns->expire_time = $expire;
     $doCampaigns->update();
     $result = $oDal->_pruneDataSummaryAdZoneAssocInactiveExpired();
//.........这里部分代码省略.........
开发者ID:Jaree,项目名称:revive-adserver,代码行数:101,代码来源:Pruning.mtpdb.test.php

示例12: Date

// | If you did not receive a copy of the new BSDlicense and are unable   |
// | to obtain it through the world-wide-web, please send a note to       |
// | pear-dev@lists.php.net so we can mail you a copy immediately.        |
// +----------------------------------------------------------------------+
// | Author: Leandro Lucarella <llucax@php.net>                           |
// +----------------------------------------------------------------------+
//
// $Id$
//
require_once 'Date.php';
require_once 'Date/Span.php';
$date = new Date();
$tmp = new Date($date);
printf("Actual date: %s\n", $date->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('0:00:00:05'));
printf("Subtracting 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('0:00:20:00'));
printf("Subtracting 20 minutes: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('0:10:00:00'));
printf("Subtracting 10 hours: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('3:00:00:00'));
printf("Subtracting 3 days: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('3:10:20:05'));
printf("Subtracting 3 days, 10 hours, 20 minutes and 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->addSpan(new Date_Span('0:00:00:05'));
开发者ID:MagnusA,项目名称:Date,代码行数:31,代码来源:test_date_methods_span.php

示例13: buildStats

 /**
  * Build global statistics array to be sent through Sync
  *
  * @return array
  */
 function buildStats()
 {
     $lastRun = OA_Dal_ApplicationVariables::get('sync_last_run');
     if ($lastRun) {
         $oStart = new Date($lastRun);
     } else {
         $oStart = new Date();
         $oStart->subtractSpan(new Date_Span('1-0-0-0'));
     }
     $oStart->setMinute(0);
     $oStart->setSecond(0);
     $oEnd = new Date();
     $oEnd->setMinute(0);
     $oEnd->setSecond(0);
     $doDsah = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDsah->selectAdd();
     $doDsah->selectAdd('date_time');
     $doDsah->selectAdd('SUM(impressions) AS total_impressions');
     $doDsah->selectAdd('SUM(clicks) AS total_clicks');
     $doDsah->whereAdd("date_time >= " . $this->oDbh->quote($oStart->format('%Y-%m-%d %H:%M:%S')));
     $doDsah->whereAdd("date_time < " . $this->oDbh->quote($oEnd->format('%Y-%m-%d %H:%M:%S')));
     $doDsah->groupBy('date_time');
     $doDsah->orderBy('date_time');
     $doDsah->find();
     $aStats = array();
     while ($doDsah->fetch()) {
         $row = $doDsah->toArray();
         $aStats[$row['date_time']] = array('impressions' => $row['total_impressions'], 'clicks' => $row['total_clicks']);
     }
     return $aStats;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:36,代码来源:Sync.php

示例14: switch

 /**
  * A private method that returns the start and end dates
  * that bound the span, based based on a pre-defined 'friendly'
  * value.
  *
  * See the {@link OA_Admin_DaySpan::setSpanPresetValue()} method
  * for the pre-defined values.
  *
  * @param string $presetValue The preset value string.
  * @return array An array of two elements, "start" and "end",
  *               representing the start and end dates of
  *               the span, respectively.
  */
 function _getSpanDates($presetValue)
 {
     switch ($presetValue) {
         case 'today':
             $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             break;
         case 'yesterday':
             $oDateStart = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             break;
         case 'this_week':
             $oDateStart = new Date(Date_Calc::beginOfWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oSixDaySpan = new Date_Span();
             $oSixDaySpan->setFromDays(6);
             $oSevenDaySpan = new Date_Span();
             $oSevenDaySpan->setFromDays(7);
             // Now have week start and end when week starts on Sunday
             // Does the user want to start on a different day?
             $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
             if ($beginOfWeek > 0) {
                 $oRequiredDaysSpan = new Date_Span();
                 $oRequiredDaysSpan->setFromDays($beginOfWeek);
                 $oDateStart->addSpan($oRequiredDaysSpan);
                 $oDateToday = new Date($this->oNowDate->format('%Y-%m-%d'));
                 if ($oDateToday->getDayOfWeek() < $beginOfWeek) {
                     $oDateStart->subtractSpan($oSevenDaySpan);
                 }
             }
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             break;
         case 'last_week':
             $oDateStart = new Date(Date_Calc::beginOfPrevWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oSixDaySpan = new Date_Span();
             $oSixDaySpan->setFromDays(6);
             $oSevenDaySpan = new Date_Span();
             $oSevenDaySpan->setFromDays(7);
             // Now have week start and end when week starts on Sunday
             // Does the user want to start on a different day?
             $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
             if ($beginOfWeek > 0) {
                 $oRequiredDaysSpan = new Date_Span();
                 $oRequiredDaysSpan->setFromDays($beginOfWeek);
                 $oDateStart->addSpan($oRequiredDaysSpan);
                 $oDateToday = new Date($this->oNowDate->format('%Y-%m-%d'));
                 if ($oDateToday->getDayOfWeek() < $beginOfWeek) {
                     $oDateStart->subtractSpan($oSevenDaySpan);
                 }
             }
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd->copy($oDateStart);
             $oDateEnd->addSpan($oSixDaySpan);
             break;
         case 'last_7_days':
             $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oOneDaySpan = new Date_Span();
             $oOneDaySpan->setFromDays(1);
             $oSevenDaySpan = new Date_Span();
             $oSevenDaySpan->setFromDays(7);
             $oDateStart->subtractSpan($oSevenDaySpan);
             $oDateEnd->subtractSpan($oOneDaySpan);
             break;
         case 'this_month':
             $oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
             break;
         case 'this_month_full':
             $oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oOneDaySpan = new Date_Span();
             $oOneDaySpan->setFromDays(1);
             $oDateEnd->subtractSpan($oOneDaySpan);
             break;
         case 'this_month_remainder':
             $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
             $oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oOneDaySpan = new Date_Span();
             $oOneDaySpan->setFromDays(1);
             $oDateEnd->subtractSpan($oOneDaySpan);
             break;
         case 'next_month':
             $oDateStart = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             $oDateEnd = new Date(Date_Calc::endOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
             break;
         case 'last_month':
             $oDateStart = new Date(Date_Calc::beginOfPrevMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
//.........这里部分代码省略.........
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:101,代码来源:DaySpan.php

示例15: convertStartEndDate

 function convertStartEndDate(&$oStartDate, &$oEndDate, $oTimezone)
 {
     if (isset($oStartDate)) {
         $oStartTz = new Date($oStartDate);
         $oStartTz->convertTZ($oTimezone);
         $oStartTz->setHour(0);
         $oStartTz->setMinute(0);
         $oStartTz->setSecond(0);
         if ($oStartTz->after($oStartDate)) {
             $oStartTz->subtractSpan(new Date_Span('1-0-0-0'));
         }
     } else {
         $oStartTz = null;
     }
     if (!isset($oEndDate)) {
         $oEndDate = new Date();
     }
     $oEndTz = new Date($oEndDate);
     $oEndTz->convertTZ($oTimezone);
     $oEndTz->setHour(0);
     $oEndTz->setMinute(0);
     $oEndTz->setSecond(0);
     $oEndTz->subtractSeconds(1);
     if ($oEndTz->after($oEndDate)) {
         $oEndTz->subtractSpan(new Date_Span('1-0-0-0'));
     }
     $oStartDate = $oStartTz;
     $oEndDate = $oEndTz;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:29,代码来源:Email.php


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