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


PHP Date::after方法代码示例

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


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

示例1: 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

示例2: after

 function after($when)
 {
     if (!is_object($when)) {
         $when = new CDate($when);
     }
     return parent::after($when);
 }
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:7,代码来源:date.class.php

示例3: after

 function after($date)
 {
     if (!$date instanceof parent) {
         $when = new CDate($date);
     } else {
         // copy the Date object to prevent changes propagation
         $when = new CDate();
         $when->copy($date);
     }
     return parent::after($when);
 }
开发者ID:hightechcompany,项目名称:dotproject,代码行数:11,代码来源:date.class.php

示例4: getLinks

 public function getLinks()
 {
     $oDate = new Date($this->oStart);
     $oNow = new Date();
     $aLinks = array();
     $baseUrl = parent::getUrl(false);
     $year = $oDate->getYear();
     $aLinks['prev'] = array('label' => '< ' . ($year - 1), 'url' => $this->appendToUrl($baseUrl, 'year=' . ($year - 1)));
     $oDate->setYear($year + 1);
     $aLinks['next'] = array('label' => $year + 1 . ' >');
     if ($oNow->after($oDate)) {
         $aLinks['next']['url'] = $this->appendToUrl($baseUrl, 'year=' . ($year + 1));
     }
     return $aLinks;
 }
开发者ID:SamWinchester,项目名称:revive-adserver,代码行数:15,代码来源:Monthly.php

示例5: testGetPlacementFirstStatsDate

 /**
  * A method to test the getPlacementFirstStatsDate() method.
  *
  * Requirements:
  * Test 1: Test with an invalid placement ID, and ensure null is returned.
  * Test 2: Test with no data in the database, and ensure current date is returned.
  * Test 3: Test with single row in the database, and ensure correct date is
  *         returned.
  * Test 4: Test with multi rows in the database, and ensure correct date is
  *         returned.
  */
 function testGetPlacementFirstStatsDate()
 {
     $conf =& $GLOBALS['_MAX']['CONF'];
     $oDbh =& OA_DB::singleton();
     $oDalStatistics = new MAX_Dal_Statistics();
     // Test 1
     $placementId = 'foo';
     $oResult = $oDalStatistics->getPlacementFirstStatsDate($placementId);
     $this->assertNull($oResult);
     // Test 2
     $placementId = 1;
     $oBeforeDate = new Date();
     sleep(1);
     $oResult = $oDalStatistics->getPlacementFirstStatsDate($placementId);
     sleep(1);
     $oAfterDate = new Date();
     $this->assertTrue(is_a($oResult, 'Date'));
     $this->assertTrue($oBeforeDate->before($oResult));
     $this->assertTrue($oAfterDate->after($oResult));
     // Test 3
     $oNow = new Date();
     $aData = array('campaignid' => $placementId, 'active' => 't', 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'), 'acls_updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idBanner1 = $this->_insertBanner($aData);
     $aData = array('day' => '2006-10-30', 'hour' => 12, 'ad_id' => $idBanner1, 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDSAH1 = $this->_insertDataSummaryAdHourly($aData);
     $oResult = $oDalStatistics->getPlacementFirstStatsDate($placementId);
     $oExpectedDate = new Date('2006-10-30 12:00:00');
     $this->assertEqual($oResult, $oExpectedDate);
     // Test 4
     $aData = array('campaignid' => $placementId, 'active' => 't', 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'), 'acls_updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idBanner2 = $this->_insertBanner($aData);
     $aData = array('campaignid' => 999, 'active' => 't', 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'), 'acls_updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idBanner3 = $this->_insertBanner($aData);
     $aData = array('day' => '2006-10-29', 'hour' => 12, 'ad_id' => $idBanner2, 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDSAH1 = $this->_insertDataSummaryAdHourly($aData);
     $aData = array('day' => '2006-10-28', 'hour' => 12, 'ad_id' => $idBanner2, 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDSAH2 = $this->_insertDataSummaryAdHourly($aData);
     $aData = array('day' => '2006-10-27', 'hour' => 12, 'ad_id' => $idBanner2, 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDSAH3 = $this->_insertDataSummaryAdHourly($aData);
     $aData = array('day' => '2006-10-26', 'hour' => 12, 'ad_id' => 999, 'updated' => $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDSAH4 = $this->_insertDataSummaryAdHourly($aData);
     $oResult = $oDalStatistics->getPlacementFirstStatsDate($placementId);
     $oExpectedDate = new Date('2006-10-27 12:00:00');
     $this->assertEqual($oResult, $oExpectedDate);
     DataGenerator::cleanUp();
 }
开发者ID:hostinger,项目名称:revive-adserver,代码行数:57,代码来源:DalStatistics.dal.test.php

示例6: 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

示例7: getBlockedOperationIntervalCount

 /**
  * A method to calculate the number of operation intervals, from a given
  * date to the end date of the campaign, an advertisement will be blocked
  * from delivering in.
  *
  * @param PEAR::Date $oStartDate A Date object representing the start of the
  *                               current operation interval.
  * @param PEAR::Date $oEndDate A Date object representing the end date of the
  *                             campaign the advertisement is in.
  * @return integer The number of operation intervals in which the advertisement
  *                 will be blocked from delivering in.
  */
 function getBlockedOperationIntervalCount($oStartDate, $oEndDate)
 {
     // Ensure the campaign end date is at the END of the day
     $oCampaignEndDate = new Date();
     $oCampaignEndDate->copy($oEndDate);
     $oCampaignEndDate->setHour(23);
     $oCampaignEndDate->setMinute(59);
     $oCampaignEndDate->setSecond(59);
     // Copy the starting date to use in a loop
     $oLoopDate = new Date();
     $oLoopDate->copy($oStartDate);
     // Count the number of blocked operation intervals
     $blockedIntervals = 0;
     while (!$oLoopDate->after($oCampaignEndDate)) {
         if ($this->deliveryBlocked($oLoopDate)) {
             // Update the count of blocked intervals, but
             // also store the start/end dates of the blocked
             // interval for later use
             $blockedIntervals++;
             $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oLoopDate);
             $this->aBlockedOperationIntervalDates[$aDates['start']->format('%Y-%m-%d %H:%M:%S')] = $aDates;
         }
         $oLoopDate->addSeconds(OX_OperationInterval::secondsPerOperationInterval());
     }
     return $blockedIntervals;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:38,代码来源:DeliveryLimitation.php

示例8: showTrendData

function showTrendData()
{
    global $badgerDb;
    global $logger;
    $logger->log('statistics::showTrendData: REQUEST_URI: ' . $_SERVER['REQUEST_URI']);
    if (!isset($_GET['accounts']) || !isset($_GET['startDate']) || !isset($_GET['endDate'])) {
        throw new BadgerException('statistics', 'missingParameter');
    }
    $accountIds = explode(';', $_GET['accounts']);
    foreach ($accountIds as $key => $val) {
        settype($accountIds[$key], 'integer');
    }
    $startDate = new Date($_GET['startDate']);
    $endDate = new Date($_GET['endDate']);
    $now = new Date();
    $now->setHour(0);
    $now->setMinute(0);
    $now->setSecond(0);
    if ($endDate->after($now)) {
        $endDate = $now;
    }
    $accountManager = new AccountManager($badgerDb);
    $totals = array();
    $accounts = array();
    $currentAccountIndex = 0;
    foreach ($accountIds as $currentAccountId) {
        $currentAccount = $accountManager->getAccountById($currentAccountId);
        $accounts[$currentAccountIndex][0] = $currentAccount->getTitle();
        $currentBalances = getDailyAmount($currentAccount, $startDate, $endDate);
        foreach ($currentBalances as $balanceKey => $balanceVal) {
            if (isset($totals[$balanceKey])) {
                $totals[$balanceKey]->add($balanceVal);
            } else {
                $totals[$balanceKey] = $balanceVal;
            }
            $accounts[$currentAccountIndex][] = $balanceVal->get();
        }
        $currentAccountIndex++;
    }
    $numDates = count($totals);
    $chart = array();
    //for documentation for the following code see: http://www.maani.us/charts/index.php?menu=Reference
    $chart['chart_type'] = "line";
    $chart['axis_category'] = array('skip' => $numDates / 12, 'font' => "Arial", 'bold' => false, 'size' => 10, 'color' => "000000", 'alpha' => 100, 'orientation' => "horizontal");
    $chart['axis_ticks'] = array('value_ticks' => true, 'category_ticks' => true, 'position' => "centered", 'major_thickness' => 2, 'major_color' => "000000", 'minor_thickness' => 1, 'minor_color' => "000000", 'minor_count' => 4);
    $chart['axis_value'] = array('min' => 0, 'max' => 0, 'steps' => 10, 'prefix' => "", 'suffix' => "", 'decimals' => 0, 'decimal_char' => ".", 'separator' => "", 'show_min' => true, 'font' => "Arial", 'bold' => false, 'size' => 10, 'color' => "000000", 'alpha' => 75, 'orientation' => "horizontal");
    $chart['chart_border'] = array('top_thickness' => 1, 'bottom_thickness' => 1, 'left_thickness' => 1, 'right_thickness' => 1, 'color' => "000000");
    $chart['chart_pref'] = array('line_thickness' => 1, 'point_shape' => "none", 'fill_shape' => false);
    $chart['chart_grid_h'] = array('thickness' => 1, 'color' => "000000", 'alpha' => 15, 'type' => "solid");
    $chart['chart_grid_v'] = array('thickness' => 1, 'color' => "000000", 'alpha' => 5, 'type' => "dashed");
    $chart['chart_rect'] = array('x' => 50, 'y' => 50, 'width' => 700, 'height' => 300, 'positive_color' => "ffffff", 'negative_color' => "000000", 'positive_alpha' => 100, 'negative_alpha' => 10);
    $chart['chart_value'] = array('prefix' => "", 'suffix' => "", 'decimals' => 0, 'decimal_char' => ".", 'separator' => "", 'position' => "cursor", 'hide_zero' => true, 'as_percentage' => false, 'font' => "Arial", 'bold' => false, 'size' => 10, 'color' => "000000", 'alpha' => 90);
    $chart['chart_transition'] = array('type' => "none", 'delay' => 1, 'duration' => 1, 'order' => "all");
    $chart['legend_rect'] = array('x' => 50, 'y' => 5, 'width' => 700, 'height' => 5, 'margin' => 5, 'fill_color' => "FFFFFF", 'fill_alpha' => 100, 'line_color' => "000000", 'line_alpha' => 100, 'line_thickness' => 1);
    $chart['legend_label'] = array('layout' => "horizontal", 'bullet' => "circle", 'font' => "Arial", 'bold' => false, 'size' => 11, 'color' => "000000", 'alpha' => 90);
    $chart['legend_transition'] = array('type' => "none", 'delay' => 1, 'duration' => 1);
    $chart['series_color'] = array("FF0000", "00FF00", "0000FF", "FF8000", "404040", "800040");
    $chart['chart_data'] = array();
    $chart['chart_data'][0][0] = '';
    if (count($accounts) > 1) {
        $chart['chart_data'][1][0] = getBadgerTranslation2('statistics', 'trendTotal');
    } else {
        $chart['chart_data'][1][0] = utf8_encode($accounts[0][0]);
    }
    foreach ($totals as $key => $val) {
        $tmp = new Date($key);
        $chart['chart_data'][0][] = $tmp->getFormatted();
        $chart['chart_data'][1][] = $val->get();
    }
    if (count($accounts) > 1) {
        foreach ($accounts as $val) {
            $chart['chart_data'][] = $val;
        }
    }
    SendChartData($chart);
}
开发者ID:BackupTheBerlios,项目名称:badger-svn,代码行数:76,代码来源:statistics.php

示例9: revenueInsertStats

 function revenueInsertStats($bannerId, $aParams, $actionType)
 {
     $aZoneIds = $this->revenueGetLinkedZones($bannerId);
     $oSpan = new Date_Span('0-1-0-0');
     $oDate = new Date($aParams['start']);
     $i = 0;
     while (!$oDate->after(new Date($aParams['end']))) {
         foreach ($aZoneIds as $zoneId) {
             $doDsah = OA_Dal::factoryDO('data_summary_ad_hourly');
             $doDsah->date_time = $oDate->format('%Y-%m-%d %H:00:00');
             $doDsah->ad_id = $bannerId;
             $doDsah->zone_id = $zoneId;
             $doDsah->creative_id = 0;
             $doDsahClone = clone $doDsah;
             if (!$doDsah->count()) {
                 $doDsahClone->updated = OA::getNow();
                 if ($doDsahClone->insert()) {
                     $i++;
                 }
             }
         }
         $oDate->addSpan($oSpan);
     }
     return $i > 0;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:25,代码来源:AdNetworks.php

示例10: Date

 /**
  * A method to check if the campaign is expired
  *
  * @return bool
  */
 function _isExpired()
 {
     static $oServiceLocator;
     // MySQL null date hardcoded for optimisation
     if (!empty($this->expire) && $this->expire != '0000-00-00') {
         if (!isset($oServiceLocator)) {
             $oServiceLocator =& OA_ServiceLocator::instance();
         }
         if (!($oNow = $oServiceLocator->get('now'))) {
             $oNow = new Date();
         }
         $oExpire = new Date($this->expire);
         $oExpire->setHour(23);
         $oExpire->setMinute(59);
         $oExpire->setSecond(59);
         if (!empty($this->clientid)) {
             // Set timezone
             $aAccounts = $this->getOwningAccountIds();
             $aPrefs = OA_Preferences::loadAccountPreferences($aAccounts[OA_ACCOUNT_ADVERTISER], true);
             if (isset($aPrefs['timezone'])) {
                 $oExpire->setTZbyID($aPrefs['timezone']);
             }
         }
         if ($oNow->after($oExpire)) {
             return true;
         }
     }
     return false;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:34,代码来源:Campaigns.php

示例11: distributeCampaignImpressions

 /**
  * A method to distribute the calculated required campaign impressions between the campaign's
  * children advertisements. Impression allocation takes in to account ad weight, and the number
  * of operations intervals the ad will be active in given date/time delivery limitations, and
  * the pattern of available impressions for the zone(s) the advertisements are linked to.
  *
  * The calculated ad impressions are written to the temporary table tmp_ad_required_impression
  * for later analysis by the {@link OA_Maintenance_Priority_AdServer_Task_AllocateZoneImpressions}
  * class.
  *
  * @param array $aCampaigns An array of {@link OX_Maintenance_Priority_Campaign} objects which require
  *                          that their total required impressions be distributed between the
  *                          component advertisements.
  */
 function distributeCampaignImpressions($aCampaigns)
 {
     // Create an array for storing required ad impressions
     $aRequiredAdImpressions = array();
     // Get the current operation interval start/end dates
     $aCurrentOperationIntervalDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($this->_getDate());
     // For each campaign
     foreach ($aCampaigns as $oCampaign) {
         OA::debug('  - Distributing impression inventory requirements for campaign ID: ' . $oCampaign->id, PEAR_LOG_DEBUG);
         $adsCount = count($oCampaign->aAds);
         OA::debug("    - Campaign has {$adsCount} ads.", PEAR_LOG_DEBUG);
         // Get date object to represent campaign expiration date
         if ($oCampaign->impressionTargetDaily > 0 || $oCampaign->clickTargetDaily > 0 || $oCampaign->conversionTargetDaily > 0) {
             // The campaign has a daily target to meet, so treat the
             // campaign as if it expires at the end of "today", regardless
             // of the existance of any activation or expiration dates that
             // may (or may not) be set for the campaign
             $oCampaignExpiryDate = new Date($this->_getDate());
             $oCampaignExpiryDate->setTZ($this->currentTz);
             $oCampaignExpiryDate->setHour(23);
             $oCampaignExpiryDate->setMinute(59);
             $oCampaignExpiryDate->setSecond(59);
             $oCampaignExpiryDate->toUTC();
             // Unless the campaign has an expiry date and it happens before the end of today
             if (!empty($oCampaign->expireTime)) {
                 if ($oCampaignExpiryDate->after($this->_getDate($oCampaign->expireTime))) {
                     $oCampaignExpiryDate = $this->_getDate($oCampaign->expireTime);
                 }
             }
         } else {
             if (!empty($oCampaign->expireTime) && ($oCampaign->impressionTargetTotal > 0 || $oCampaign->clickTargetTotal > 0 || $oCampaign->conversionTargetTotal > 0)) {
                 // The campaign has an expiration date, and has some kind of
                 // (total) inventory requirement, so treat the campaign as if
                 // it expires at the expiration date/time
                 $oCampaignExpiryDate = $this->_getDate($oCampaign->expireTime);
             } else {
                 // Error! There should not be any other kind of high-priority
                 // campaign in terms of activation/expiration dates and
                 // either (total) inventory requirements or daily targets
                 $message = "- Error calculating the end date for Campaign ID {$oCampaign->id}";
                 OA::debug($message, PEAR_LOG_ERR);
                 continue;
             }
         }
         // Determine number of remaining operation intervals for campaign
         $message = "    - Calculating campaign remaining operation intervals.";
         OA::debug($message, PEAR_LOG_DEBUG);
         $campaignRemainingOperationIntervals = OX_OperationInterval::getIntervalsRemaining($aCurrentOperationIntervalDates['start'], $oCampaignExpiryDate);
         // For all ads in the campaign, determine:
         // - If the ad is capable of delivery in the current operation
         //   interval, or not, based on if it is linked to any zones, and,
         //   if so:
         // - If the ad is capable of delivery in the current operation
         //   interval, or not, based on delivery limitation(s), and if so;
         // - The result of the weight of the ad multiplied by the
         //   number of operation intervals remaining in which the ad
         //   is capable of delivering
         $aAdZones = array();
         $aAdDeliveryLimitations = array();
         $aAdBlockedForCurrentOI = array();
         $aAdWeightRemainingOperationIntervals = array();
         $aInvalidAdIds = array();
         reset($oCampaign->aAds);
         while (list($key, $oAd) = each($oCampaign->aAds)) {
             // Only calculate values for active ads
             if ($oAd->active && $oAd->weight > 0) {
                 $message = "    - Calculating remaining operation intervals for ad ID: {$oAd->id}";
                 OA::debug($message, PEAR_LOG_DEBUG);
                 // Get all zones associated with the ad
                 $aAdsZones = $this->oDal->getAdZoneAssociationsByAds(array($oAd->id));
                 $aAdZones[$oAd->id] = @$aAdsZones[$oAd->id];
                 if (is_null($aAdZones[$oAd->id])) {
                     $aInvalidAdIds[] = $oAd->id;
                     $message = "      - Ad ID {$oAd->id} has no linked zones, will skip...";
                     OA::debug($message, PEAR_LOG_ERR);
                     continue;
                 }
                 // Prepare a delivery limitation object for the ad
                 $aAdDeliveryLimitations[$oAd->id] = new OA_Maintenance_Priority_DeliveryLimitation($oAd->getDeliveryLimitations());
                 // Is the ad blocked from delivering in the current operation interval?
                 $aAdBlockedForCurrentOI[$oAd->id] = $aAdDeliveryLimitations[$oAd->id]->deliveryBlocked($aCurrentOperationIntervalDates['start']);
                 // Determine how many operation intervals remain that the ad can deliver in
                 $adRemainingOperationIntervals = $aAdDeliveryLimitations[$oAd->id]->getActiveAdOperationIntervals($campaignRemainingOperationIntervals, $aCurrentOperationIntervalDates['start'], $oCampaignExpiryDate);
                 // Determine the value of the ad weight multiplied by the number
                 // of operation intervals remaining that the ad can deliver in
                 if ($oAd->weight > 0) {
//.........这里部分代码省略.........
开发者ID:akirsch,项目名称:revive-adserver,代码行数:101,代码来源:GetRequiredAdImpressions.php

示例12: getDayArray

 /**
  * A method to return an array containing the days in the span, including the start
  * and end days, where each day in the array is formatted as a string.
  *
  * @param string $format An optional PEAR::Date compatible format string.
  * @return array An array of the days in the span.
  */
 function getDayArray($format = '%Y-%m-%d')
 {
     $aDays = array();
     $oDate = new Date();
     $oDate->copy($this->oStartDate);
     while (!$oDate->after($this->oEndDate)) {
         $aDays[] = $oDate->format($format);
         $oDate->addSeconds(SECONDS_PER_DAY);
     }
     return $aDays;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:18,代码来源:DaySpan.php

示例13: transferFormerFinishedTransactions

function transferFormerFinishedTransactions($account)
{
    global $us;
    if ($us->getProperty('autoExpandPlannedTransactions') == false) {
        return;
    }
    $now = new Date();
    $now->setHour(0);
    $now->setMinute(0);
    $now->setSecond(0);
    $account->setType('planned');
    $account->setFilter(array(array('key' => 'beginDate', 'op' => 'le', 'val' => $now)));
    try {
        $lastInsertDate = $us->getProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions');
    } catch (BadgerException $ex) {
        $lastInsertDate = new Date('1000-01-01');
    }
    $us->setProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions', $now);
    if (!$lastInsertDate->before($now)) {
        return;
    }
    while ($currentTransaction = $account->getNextPlannedTransaction()) {
        $date = new Date($currentTransaction->getBeginDate());
        $dayOfMonth = $date->getDay();
        //While we are before now and the end date of this transaction
        while (!$date->after($now) && !$date->after(is_null($tmp = $currentTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
            if ($date->after($lastInsertDate)) {
                $account->addFinishedTransaction($currentTransaction->getAmount(), $currentTransaction->getTitle(), $currentTransaction->getDescription(), new Date($date), $currentTransaction->getTransactionPartner(), $currentTransaction->getCategory(), $currentTransaction->getOutsideCapital(), false, true);
            }
            //do the date calculation
            switch ($currentTransaction->getRepeatUnit()) {
                case 'day':
                    $date->addSeconds($currentTransaction->getRepeatFrequency() * 24 * 60 * 60);
                    break;
                case 'week':
                    $date->addSeconds($currentTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
                    break;
                case 'month':
                    //Set the month
                    $date = new Date(Date_Calc::endOfMonthBySpan($currentTransaction->getRepeatFrequency(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
                    //And count back as far as the last valid day of this month
                    while ($date->getDay() > $dayOfMonth) {
                        $date->subtractSeconds(24 * 60 * 60);
                    }
                    break;
                case 'year':
                    $newYear = $date->getYear() + $currentTransaction->getRepeatFrequency();
                    if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
                        $date->setDay(28);
                    } else {
                        $date->setDay($dayOfMonth);
                    }
                    $date->setYear($newYear);
                    break;
                default:
                    throw new BadgerException('Account', 'IllegalRepeatUnit', $currentTransaction->getRepeatUnit());
                    exit;
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:badger-svn,代码行数:61,代码来源:accountCommon.php

示例14: getDailyAmount

/**
 * Returns the Account balance for $account at the end of each day between $startDate and $endDate.
 * 
 * Considers the planned transactions of $account.
 * 
 * @param object $account The Account object for which the balance should be calculated. 
 * It should be 'fresh', i. e. no transactions of any type should have been fetched from it.
 * @param object $startDate The first date the balance should be calculated for as Date object.
 * @param object $endDate The last date the balance should be calculated for as Date object.
 * @return array Array of Amount objects corresponding to the balance of $account at each day between
 * $startDate and $endDate. The array keys are the dates as ISO-String (yyyy-mm-dd). 
 */
function getDailyAmount($account, $startDate, $endDate, $isoDates = true, $startWithBalance = false, $includePlannedTransactions = false)
{
    global $badgerDb;
    $account->setTargetFutureCalcDate($endDate);
    $account->setOrder(array(array('key' => 'valutaDate', 'dir' => 'asc')));
    if (!$includePlannedTransactions) {
        $account->setType('finished');
    }
    $result = array();
    $startDate->setHour(0);
    $startDate->setMinute(0);
    $startDate->setSecond(0);
    $endDate->setHour(0);
    $endDate->setMinute(0);
    $endDate->setSecond(0);
    $currentDate = new Date($startDate);
    $currentAmount = new Amount();
    $firstRun = true;
    //foreach transaction
    while ($currentTransaction = $account->getNextTransaction()) {
        if ($currentDate->after($endDate)) {
            //we reached $endDAte
            break;
        }
        if ($firstRun && $startWithBalance) {
            $currentAmount = new Amount($currentTransaction->getBalance());
            $currentAmount->sub($currentTransaction->getAmount());
            $firstRun = false;
        }
        //fill all dates between last and this transaction with the old amount
        while (is_null($tmp = $currentTransaction->getValutaDate()) ? false : $currentDate->before($tmp)) {
            if ($isoDates) {
                $key = $currentDate->getDate();
            } else {
                $key = $currentDate->getTime();
            }
            $result[$key] = new Amount($currentAmount);
            $currentDate->addSeconds(24 * 60 * 60);
            if ($currentDate->after($endDate)) {
                //we reached $endDAte
                break;
            }
        }
        $currentAmount->add($currentTransaction->getAmount());
    }
    if ($firstRun && $startWithBalance) {
        $newAccountManager = new AccountManager($badgerDb);
        $newAccount = $newAccountManager->getAccountById($account->getId());
        $newAccount->setOrder(array(array('key' => 'valutaDate', 'dir' => 'asc')));
        while ($newTransaction = $newAccount->getNextTransaction()) {
            $currentDate = $newTransaction->getValutaDate();
            if ($currentDate->after($startDate)) {
                //we reached $endDAte
                break;
            }
            $currentAmount = new Amount($newTransaction->getBalance());
        }
        $currentDate = new Date($startDate);
        if ($isoDates) {
            $key = $currentDate->getDate();
        } else {
            $key = $currentDate->getTime();
        }
        $result[$key] = new Amount($currentAmount);
    }
    //fill all dates after the last transaction with the newest amount
    while (Date::compare($currentDate, $endDate) <= 0) {
        if ($isoDates) {
            $key = $currentDate->getDate();
        } else {
            $key = $currentDate->getTime();
        }
        $result[$key] = new Amount($currentAmount);
        $currentDate->addSeconds(24 * 60 * 60);
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:badger-svn,代码行数:89,代码来源:accountCommon.php

示例15: Date

 /**
  * A method to check if the campaign is expired
  *
  * @return bool
  */
 function _isExpired()
 {
     static $oServiceLocator;
     if (!empty($this->expire_time) && $this->expire_time != OX_DATAOBJECT_NULL) {
         if (!isset($oServiceLocator)) {
             $oServiceLocator =& OA_ServiceLocator::instance();
         }
         if (!($oNow = $oServiceLocator->get('now'))) {
             $oNow = new Date();
         }
         $oNow->toUTC();
         $oExpire = new Date($this->expire_time);
         $oExpire->setTZbyID('UTC');
         if ($oNow->after($oExpire)) {
             return true;
         }
     }
     return false;
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:24,代码来源:Campaigns.php


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