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


PHP Date::setDay方法代码示例

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


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

示例1: create

  static public function create($year=0, $month=0, $day=0, $hour=0, $minute=0, $second=0)
  {
    $d = new Date();

    $d->setYear($year);
    $d->setMonth($month);
    $d->setDay($day);
    $d->setHour($hour);
    $d->setMinute($minute);
    $d->setSecond($second);

    return $d;
  }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:13,代码来源:Date.class.php

示例2: checkDates

 /**
  * Check start/end dates - note that check is the reverse of normal check:
  * if the operation interval is <= 60, must be start/end of an hour, to
  * make sure we update all the operation intervals in the hour, and if
  * the operation interval > 60, must be the start/end of an operation
  * interval, to make sure we update all the hours in the operation interval.
  *
  * @static
  * @param Date $oStartDate
  * @param Date $oEndDate
  * @return boolean
  */
 function checkDates($oStartDate, $oEndDate)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     $operationInterval = $aConf['maintenance']['operation_interval'];
     if ($operationInterval <= 60) {
         // Must ensure that only one hour is being summarised
         if (!OX_OperationInterval::checkDatesInSameHour($oStartDate, $oEndDate)) {
             return false;
         }
         // Now check that the start and end dates are match the start and
         // end of the hour
         $oHourStart = new Date();
         $oHourStart->setYear($oStartDate->getYear());
         $oHourStart->setMonth($oStartDate->getMonth());
         $oHourStart->setDay($oStartDate->getDay());
         $oHourStart->setHour($oStartDate->getHour());
         $oHourStart->setMinute('00');
         $oHourStart->setSecond('00');
         $oHourEnd = new Date();
         $oHourEnd->setYear($oEndDate->getYear());
         $oHourEnd->setMonth($oEndDate->getMonth());
         $oHourEnd->setDay($oEndDate->getDay());
         $oHourEnd->setHour($oEndDate->getHour());
         $oHourEnd->setMinute('59');
         $oHourEnd->setSecond('59');
         if (!$oStartDate->equals($oHourStart)) {
             return false;
         }
         if (!$oEndDate->equals($oHourEnd)) {
             return false;
         }
     } else {
         // Must ensure that only one operation interval is being summarised
         $operationIntervalID = OX_OperationInterval::convertDaySpanToOperationIntervalID($oStartDate, $oEndDate, $operationInterval);
         if (is_bool($operationIntervalID) && !$operationIntervalID) {
             return false;
         }
         // Now check that the start and end dates match the start and end
         // of the operation interval
         list($oOperationIntervalStart, $oOperationIntervalEnd) = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oStartDate, $operationInterval);
         if (!$oStartDate->equals($oOperationIntervalStart)) {
             return false;
         }
         if (!$oEndDate->equals($oOperationIntervalEnd)) {
             return false;
         }
     }
     return true;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:61,代码来源:Regenerate.php

示例3: create_conference

function create_conference() {
  global $log, $spUser,$_POST,$data; 
  $msgs = array(); 
  // check the title
  if (!$_POST[conference_name] ) { 
    $msgs[] = "Conference must have a title";
    return $msgs  ; 
  } 

  // validate the date ... 
  if (($conference_uts = strtotime($_POST[conference_date]))===false )  { 
    $msgs[] = "Conference date is an Invalid date.";
    return $msgs  ; 
  } 
  list ($m,$d,$y) = split('-',$_POST[conference_date]);

  // Make date objects...
  $confDate = new Date(); 
  $confDate->setMonth($m); 
  $confDate->setYear($y); 
  $confDate->setDay($d); 
  $confDate->setHour(0); 
  $confDate->setMinute(0); 
  $confDate->setSecond(0); 
  $beginTime = $confDate; 
  $endTime = $confDate; 

  list ($beginHour,$beginMinute) = split(':', $_POST[begin_time] ); 
  list ($endHour,$endMinute) = split(':', $_POST[end_time] ); 

  $beginTime->setHour($beginHour); 
  $beginTime->setMinute($beginMinute); 
  $endTime->setHour($endHour); 
  $endTime->setMinute($endMinute); 

  // see if it's the past
  if ($endTime->isPast() ){ 
    $msgs[] = "Conference date is in the Past.";
    return $msgs ; 
  }   

  // Make sure the end time is not less than the begin time
  if (Date::compare($endTime, $beginTime) != 1     ){ 
    $msgs[] = "Start time must be before end time.";
    return $msgs ; 
  }   
  
  // create a new Conference object

  $conference = new Conference($data->db, $spUser->username,$spUser->domain); 

  // get the user's company Id and load the companies constraints
  $conference->getCompanyId(); 
  $conference->loadConstraints() ; 
  // set the date objects.
  $conference->conferenceDate = $confDate; 
  $conference->beginTime = $beginTime; 
  $conference->endTime = $endTime; 
  $conference->conferenceName = $_POST[conference_name] ; 

  // Is the conference too long
  if (!$conference->isMaxTime()) {
    $msgs[] = "Your conference exceeds the maximum amount of minutes.";
    return $msgs  ; 
  } 
  
  // Are there other conferences scheduled for this time.
  if (!$conference->isMaxConcurrent()) {
    $msgs[] = "Your company has other conferences scheduled for this time.";
    return $msgs  ; 
  } 
  $error = "nay!"; 
  if ($conference->create($error) ) { 
    $msgs[] = "Conference created id = " . $conference->conferenceId;
    Header("Location: conference.php?msg=Conference created ") ;
  } else {
    $msgs[] = "Failed to create conference. ";
     $msgs[] = "$error";
  } 
  $owner = new Invitee($data->db, $conference->conferenceId);
  $owner->domain = $spUser->domain;
  $owner->username = $spUser->username;
  $owner->companyId = $conference->companyId; 
  $owner->inviteeEmail = $spUser->dbFields[email_address] ; 
  $owner->ownerFlag =  1; 
  $owner->inviteeName = $spUser->dbFields[first_name] . " " . $spUser->dbFields[last_name] ; 
  // genereate that unique code
  $owner->generateInviteeCode();   
  $owner->create();   
  $owner->sendNotify();   
  
  return $msgs  ; 


}
开发者ID:BackupTheBerlios,项目名称:sipums,代码行数:95,代码来源:new_conference.php

示例4: getMtRevenue

 /**
  * A method to get the hourly revenuo of a monthly tenancy campaign
  *
  * Monthly tenancy calculation sponsored by www.admost.nl
  *
  * @param array $aInfo The finance information, as returned by _saveSummaryGetAdFinanceInfo
  * @param Date $oStartDate
  * @param Date $oEndDate
  * @param string $table
  * @return double
  */
 function getMtRevenue($aInfo, $oStartDate, $oEndDate, $table)
 {
     OA::debug(sprintf("  - Calculating MT revenue for banner [id%d] between %s and %s:", $aInfo['ad_id'], $oStartDate->format('%Y-%m-%d %H:%M:%S %Z'), $oEndDate->format('%Y-%m-%d %H:%M:%S %Z')), PEAR_LOG_DEBUG);
     $aConf = $GLOBALS['_MAX']['CONF'];
     $oMonthStart = new Date($oStartDate);
     // Set timezone
     if (!empty($aInfo['advertiser_id'])) {
         $doClient = OA_Dal::staticGetDO('clients', $aInfo['advertiser_id']);
         $aAdvertiserPrefs = OA_Preferences::loadAccountPreferences($doClient->account_id, true);
         if (!empty($aAdvertiserPrefs['timezone'])) {
             $oMonthStart->convertTZbyID($aAdvertiserPrefs['timezone']);
         }
     }
     // Get ad/zone combinations for the campaign
     if (!isset($this->aMtRevenueCache[$aInfo['campaign_id']])) {
         $query = "\n                SELECT\n                    COUNT(*) as cnt\n                FROM\n                    " . $this->oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table'][$table], true) . " d JOIN\n                    " . $this->oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['banners'], true) . " a ON (a.bannerid = d.ad_id)\n                WHERE\n                    a.campaignid = {$aInfo['campaign_id']}\n                    AND d.date_time >= " . $this->oDbh->quote($oStartDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp') . "\n                    AND d.date_time <= " . $this->oDbh->quote($oEndDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp');
         $this->aMtRevenueCache[$aInfo['campaign_id']] = $this->oDbh->query($query)->fetchOne();
     }
     $oMonthStart->setDay(1);
     $oMonthStart->setHour(0);
     $oMonthStart->setMinute(0);
     $oMonthStart->setSecond(0);
     OA::debug(sprintf("    - Month start: %s", $oMonthStart->format('%Y-%m-%d %H:%M:%S %Z')), PEAR_LOG_DEBUG);
     $daysInMonth = $oMonthStart->getDaysInMonth();
     OA::debug(sprintf("    - Days in month: %d", $daysInMonth), PEAR_LOG_DEBUG);
     $oMonthEnd = new Date($oMonthStart);
     $oMonthEnd->setDay($daysInMonth);
     $oMonthEnd = $oMonthEnd->getNextDay();
     $oMonthEnd->setTZ($oMonthStart->tz);
     OA::debug(sprintf("    - Month end: %s", $oMonthEnd->format('%Y-%m-%d %H:%M:%S %Z')), PEAR_LOG_DEBUG);
     $oDiff = new Date_Span();
     $oDiff->setFromDateDiff($oMonthEnd, $oMonthStart);
     $hoursPerMonth = ceil($oDiff->toHours());
     OA::debug(sprintf("    - Hours per month: %d", $hoursPerMonth), PEAR_LOG_DEBUG);
     $oDiff = new Date_Span();
     $oDiff->setFromDateDiff($oEndDate, $oStartDate);
     $hoursPerInterval = ceil($oDiff->toHours());
     OA::debug(sprintf("    - Hours per interval: %d", $hoursPerInterval), PEAR_LOG_DEBUG);
     $adZoneCombinations = $this->aMtRevenueCache[$aInfo['campaign_id']];
     OA::debug(sprintf("    - Ad/zone/OI combinations for campaign [id%d]: %d", $aInfo['campaign_id'], $this->aMtRevenueCache[$aInfo['campaign_id']]), PEAR_LOG_DEBUG);
     $result = $aInfo['revenue'] / $hoursPerMonth * $hoursPerInterval / $adZoneCombinations;
     OA::debug(sprintf("    - Result: %0.4f", $result), PEAR_LOG_DEBUG);
     return $result;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:55,代码来源:Statistics.php

示例5: priv1

        trace("__LINE__", __LINE__);
        $this->priv1();
        $this->spf1();
    }
    // public vs. private doesn't matter
    private function priv1()
    {
        echo "Inside " . __METHOD__ . "\n";
        trace("__FUNCTION__", __FUNCTION__);
    }
    public static function spf1()
    {
        echo "Inside " . __METHOD__ . "\n";
        trace("__FUNCTION__", __FUNCTION__);
    }
}
$date1 = new Date();
$date1->setDay(22);
echo "-----------------------------------------\n";
class DatePlus extends Date
{
    public function xx()
    {
        trace("__CLASS__", __CLASS__);
        echo "Inside " . __METHOD__ . "\n";
        trace("__FUNCTION__", __FUNCTION__);
    }
}
$datePlus1 = new DatePlus();
$datePlus1->xx();
include_once 'includefile.inc';
开发者ID:mfsousa,项目名称:php-langspec,代码行数:31,代码来源:core_predefined_constants.php

示例6: explode

 /**
  * Convert Date from iso 8601 format.
  *
  * @access private
  *
  * @param string $date  date string in ISO 8601 format
  * @param PEAR::Date &$oResult  transformed date
  * @param XML_RPC_Response &$oResponseWithError  response with error message
  *
  * @return boolean  shows true if method was executed successfully
  */
 function _convertDateFromIso8601Format($date, &$oResult, &$oResponseWithError)
 {
     $datetime = explode('T', $date);
     $year = substr($datetime[0], 0, strlen($datetime[0]) - 4);
     $month = substr($datetime[0], -4, 2);
     $day = substr($datetime[0], -2, 2);
     // Explicitly allow the "zero date" value to be set
     if ($year == 0 && $month == 0 && $day == 0) {
         return new Date('0000-00-00');
     }
     if ($year < 1970 || $year > 2038) {
         $oResponseWithError = XmlRpcUtils::generateError('Year should be in range 1970-2038');
         return false;
     } elseif ($month < 1 || $month > 12) {
         $oResponseWithError = XmlRpcUtils::generateError('Month should be in range 1-12');
         return false;
     } elseif ($day < 1 || $day > 31) {
         $oResponseWithError = XmlRpcUtils::generateError('Day should be in range 1-31');
         return false;
     } else {
         $oResult = new Date();
         $oResult->setYear($year);
         $oResult->setMonth($month);
         $oResult->setDay($day);
         return true;
     }
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:38,代码来源:XmlRpcUtils.php

示例7: showSelectPage

function showSelectPage()
{
    global $tpl;
    global $us;
    global $badgerDb;
    handleOldFinishedTransactions(new AccountManager($badgerDb));
    $widgets = new WidgetEngine($tpl);
    $widgets->addCalendarJS();
    $widgets->addToolTipJS();
    $tpl->addJavaScript("js/behaviour.js");
    $tpl->addJavaScript("js/prototype.js");
    $tpl->addJavaScript("js/statistics.js");
    $tpl->addHeaderTag('<script type="text/javascript">var badgerHelpChapter = "Statistiken";</script>');
    $dataGrid = new DataGrid($tpl);
    $dataGrid->sourceXML = BADGER_ROOT . "/core/XML/getDataGridXML.php?q=AccountManager";
    $dataGrid->headerName = array(getBadgerTranslation2('statistics', 'accColTitle'), getBadgerTranslation2('statistics', 'accColBalance'), getBadgerTranslation2('statistics', 'accColCurrency'));
    $dataGrid->columnOrder = array("title", "balance", 'currency');
    $dataGrid->initialSort = "title";
    $dataGrid->initialSortDirection = "asc";
    $dataGrid->headerSize = array(160, 100, 75);
    $dataGrid->cellAlign = array("left", 'right', 'left');
    $dataGrid->width = '30em';
    $dataGrid->height = '7em';
    $dataGrid->initDataGridJS();
    try {
        $preselectedAccounts = $us->getProperty('statisticsPreselectedAccounts');
        foreach ($preselectedAccounts as $currentPreselectedAccount) {
            $tpl->addOnLoadEvent("dgPreselectId('{$currentPreselectedAccount}');");
        }
    } catch (BadgerException $ex) {
    }
    $tpl->addOnLoadEvent("Behaviour.register(statisticsBehaviour);");
    $tpl->addOnLoadEvent("Behaviour.apply();");
    $widgets->addNavigationHead();
    $selectTitle = getBadgerTranslation2('statistics', 'pageTitle');
    echo $tpl->getHeader($selectTitle);
    $widgets->addToolTipLayer();
    $selectFormAction = BADGER_ROOT . '/modules/statistics/statistics.php';
    $graphTypeText = getBadgerTranslation2('statistics', 'type');
    $categoryTypeText = getBadgerTranslation2('statistics', 'category');
    $timeFrameText = getBadgerTranslation2('statistics', 'period');
    $summarizeCategoriesText = getBadgerTranslation2('statistics', 'catMerge');
    $accountsText = getBadgerTranslation2('statistics', 'accounts');
    $differentCurrencyWarningText = getBadgerTranslation2('statistics', 'attention');
    $fromText = getBadgerTranslation2('statistics', 'from');
    $toText = getBadgerTranslation2('statistics', 'to');
    $trendRadio = $widgets->createField('mode', null, 'trendPage', '', false, 'radio', 'checked="checked"');
    $trendLabel = $widgets->createLabel('mode', getBadgerTranslation2('statistics', 'trend'));
    $categoryRadio = $widgets->createField('mode', null, 'categoryPage', '', false, 'radio');
    $categoryLabel = $widgets->createLabel('mode', getBadgerTranslation2('statistics', 'categories'));
    $accountSelect = $dataGrid->writeDataGrid();
    $accountField = $widgets->createField('accounts', null, null, '', false, 'hidden');
    $monthArray = array('fullYear' => getBadgerTranslation2('statistics', 'fullYear'), '1' => getBadgerTranslation2('statistics', 'jan'), '2' => getBadgerTranslation2('statistics', 'feb'), '3' => getBadgerTranslation2('statistics', 'mar'), '4' => getBadgerTranslation2('statistics', 'apr'), '5' => getBadgerTranslation2('statistics', 'may'), '6' => getBadgerTranslation2('statistics', 'jun'), '7' => getBadgerTranslation2('statistics', 'jul'), '8' => getBadgerTranslation2('statistics', 'aug'), '9' => getBadgerTranslation2('statistics', 'sep'), '10' => getBadgerTranslation2('statistics', 'oct'), '11' => getBadgerTranslation2('statistics', 'nov'), '12' => getBadgerTranslation2('statistics', 'dec'));
    $monthSelect = $widgets->createSelectField('monthSelect', $monthArray, 'fullYear', '', false, 'onchange="updateDateRange();"');
    $now = new Date();
    $beginOfYear = new Date();
    $beginOfYear->setMonth(1);
    $beginOfYear->setDay(1);
    $yearInput = $widgets->createField('yearSelect', 4, $now->getYear(), '', false, 'text', 'onchange="updateDateRange();"');
    $startDateField = $widgets->addDateField("startDate", $beginOfYear->getFormatted());
    $endDateField = $widgets->addDateField("endDate", $now->getFormatted());
    $inputRadio = $widgets->createField('type', null, 'i', '', false, 'radio', 'checked="checked"');
    $inputLabel = $widgets->createLabel('type', getBadgerTranslation2('statistics', 'income'));
    $outputRadio = $widgets->createField('type', null, 'o', '', false, 'radio');
    $outputLabel = $widgets->createLabel('type', getBadgerTranslation2('statistics', 'expenses'));
    $summarizeRadio = $widgets->createField('summarize', null, 't', '', false, 'radio', 'checked="checked"');
    $summarizeLabel = $widgets->createLabel('summarize', getBadgerTranslation2('statistics', 'subCat'));
    $distinguishRadio = $widgets->createField('summarize', null, 'f', '', false, 'radio');
    $distinguishLabel = $widgets->createLabel('summarize', getBadgerTranslation2('statistics', 'subCat2'));
    $dateFormatField = $widgets->createField('dateFormat', null, $us->getProperty('badgerDateFormat'), null, false, 'hidden');
    $errorMsgAccountMissingField = $widgets->createField('errorMsgAccountMissing', null, getBadgerTranslation2('statistics', 'errorMissingAcc'), null, false, 'hidden');
    $errorMsgStartBeforeEndField = $widgets->createField('errorMsgStartBeforeEnd', null, getBadgerTranslation2('statistics', 'errorDate'), null, false, 'hidden');
    $errorMsgEndInFutureField = $widgets->createField('errorMsgEndInFuture', null, getBadgerTranslation2('statistics', 'errorEndDate'), null, false, 'hidden');
    $submitButton = $widgets->createButton('submit', getBadgerTranslation2('statistics', 'showButton'), 'submitSelect();', "Widgets/accept.gif");
    eval('echo "' . $tpl->getTemplate('statistics/select') . '";');
    eval('echo "' . $tpl->getTemplate('badgerFooter') . '";');
}
开发者ID:BackupTheBerlios,项目名称:badger-svn,代码行数:77,代码来源:statistics.php

示例8: expandPlannedTransactions

 /**
  * Expands the planned transactions.
  * 
  * All occurences of planned transactions between now and the targetFutureCalcDate will be inserted
  * in finishedTransactions. For distinction the planned transactions will have a 'p' as first character
  * in their id.
  * 
  * @throws BadgerException If an illegal repeat unit is used.
  */
 public function expandPlannedTransactions()
 {
     $now = new Date();
     $now->setHour(0);
     $now->setMinute(0);
     $now->setSecond(0);
     foreach ($this->plannedTransactions as $currentTransaction) {
         $date = new Date($currentTransaction->getBeginDate());
         $dayOfMonth = $date->getDay();
         //While we have not reached targetFutureCalcDate
         while ($this->targetFutureCalcDate->after($date) && !$date->after(is_null($tmp = $currentTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
             $inRange = true;
             //Check if there is one or more valutaDate filter and apply them
             foreach ($this->filter as $currentFilter) {
                 if ($currentFilter['key'] == 'valutaDate') {
                     switch ($currentFilter['op']) {
                         case 'eq':
                             if (Date::compare($date, $currentFilter['val']) != 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'lt':
                             if (Date::compare($date, $currentFilter['val']) >= 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'le':
                             if (Date::compare($date, $currentFilter['val']) > 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'gt':
                             if (Date::compare($date, $currentFilter['val']) <= 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'ge':
                             if (Date::compare($date, $currentFilter['val']) < 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'ne':
                             if (Date::compare($date, $currentFilter['val']) == 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'bw':
                         case 'ew':
                         case 'ct':
                             if (strncasecmp($date->getFormatted(), $currentFilter['val']->getFormatted(), 9999) != 0) {
                                 $inRange = false;
                             }
                             break;
                     }
                     if (!$inRange) {
                         break;
                     }
                 }
             }
             if (!$date->before($now) && $inRange) {
                 $this->finishedTransactions[] = new FinishedTransaction($this->badgerDb, $this, 'p' . $currentTransaction->getId() . '_' . $date->getDate(), $currentTransaction->getTitle(), $currentTransaction->getAmount(), $currentTransaction->getDescription(), new Date($date), $currentTransaction->getTransactionPartner(), $currentTransaction->getCategory(), $currentTransaction->getOutsideCapital(), false, true, $currentTransaction, 'PlannedTransaction');
             }
             //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,代码行数:101,代码来源:Account.class.php

示例9: previousOccurence

 private function previousOccurence($date, $start = null)
 {
     if (is_null($start)) {
         $start = $this->beginDate;
     }
     $dayOfMonth = $start->getDay();
     //do the date calculation
     switch ($this->repeatUnit) {
         case 'day':
             $date->subtractSeconds($this->repeatFrequency * 24 * 60 * 60);
             break;
         case 'week':
             $date->subtractSeconds($this->repeatFrequency * 7 * 24 * 60 * 60);
             break;
         case 'month':
             //Set the month
             $date = new Date(Date_Calc::endOfMonthBySpan(-$this->repeatFrequency, $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() - $this->repeatFrequency;
             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', $this->repeatUnit);
             exit;
     }
     //switch
     return $date;
 }
开发者ID:BackupTheBerlios,项目名称:badger-svn,代码行数:38,代码来源:PlannedTransaction.class.php

示例10: createCalendarioMes

 public static function createCalendarioMes($mes, $ano, $modo)
 {
     //include_once('CalendarShow.class.php');
     $cal = new CalendarShow();
     $fecha = new Date();
     $fecha->setDay(1);
     $fecha->setMonth($mes);
     $fecha->setYear($ano);
     $fecha_uno = $fecha->toString(FMT_DATEMYSQL);
     $fecha->addMonths(1);
     $fecha->addDays(-1);
     $fecha_dos = $fecha->toString(FMT_DATEMYSQL);
     $diasEvento = array();
     $diasTareas = array();
     $c1 = TareaPeer::getCriterioAlcance();
     $crit0 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL);
     $crit1 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_dos . " 23:59:59", Criteria::LESS_EQUAL);
     $crit0->addAnd($crit1);
     $crit2 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL);
     $crit3 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_dos . " 23:59:59", Criteria::LESS_EQUAL);
     $crit2->addAnd($crit3);
     $crit0->addOr($crit2);
     $c1->add($crit0);
     $c1->setDistinct();
     $dias = TareaPeer::doSelect($c1);
     $ruta = UsuarioPeer::getRuta();
     foreach ($dias as $dia) {
         $fecha_inicio = $dia->getFechaInicio('Y-m-d');
         $fecha_fin = $dia->getFechaVencimiento('Y-m-d');
         if ($fecha_inicio == $fecha_fin) {
             if ($dia->getEsEvento() == '1') {
                 if (!isset($diasEvento[$fecha_inicio])) {
                     $diasEvento[$fecha_inicio] = "";
                 }
                 //$diasEvento[$fecha_inicio] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
                 $diasEvento[$fecha_inicio] .= $dia->getResumen();
             } else {
                 if (!isset($diasTareas[$fecha_inicio])) {
                     $diasTareas[$fecha_inicio] = "";
                 }
                 //$diasTareas[$fecha_inicio] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
                 $diasTareas[$fecha_inicio] .= $dia->getResumen();
             }
         } else {
             if ($dia->getEsEvento() == '1') {
                 if (!isset($diasEvento[$fecha_inicio])) {
                     $diasEvento[$fecha_inicio] = "";
                 }
                 if (!isset($diasEvento[$fecha_fin])) {
                     $diasEvento[$fecha_fin] = "";
                 }
                 //$diasEvento[$fecha_inicio] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Inicio Evento: ".$dia->getResumen()."</a></div>";
                 $diasEvento[$fecha_inicio] .= $dia->getResumen();
                 //$diasEvento[$fecha_fin] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Vencimiento Evento: ".$dia->getResumen()."</a></div>";
                 $diasEvento[$fecha_fin] .= $dia->getResumen();
             } else {
                 if (!isset($diasTareas[$fecha_inicio])) {
                     $diasTareas[$fecha_inicio] = "";
                 }
                 if (!isset($diasTareas[$fecha_fin])) {
                     $diasTareas[$fecha_fin] = "";
                 }
                 //$diasTareas[$fecha_inicio] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Inicio Tarea: ".$dia->getResumen()."</a></div>";
                 $diasTareas[$fecha_inicio] .= $dia->getResumen();
                 //$diasTareas[$fecha_fin] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Vencimiento Tarea: ".$dia->getResumen()."</a></div>";
                 $diasTareas[$fecha_fin] .= $dia->getResumen();
             }
         }
         /*
         if ($dia->getEsEvento() == '1') {
             if (isset($diasEvento[$fecha]))
                 $diasEvento[$fecha] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
             else
                 $diasEvento[$fecha] = "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";		 		
         }
         else {
         		if (isset($diasTareas[$fecha]))
                 $diasTareas[$fecha] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
         		else
         		    $diasTareas[$fecha] = "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
         }
         */
         $filters = array();
         $filters['fecha_inicio']['from'] = $dia->getFechaInicio('d/m/Y');
         $filters['fecha_inicio']['to'] = $dia->getFechaVencimiento('d/m/Y');
         if ($modo) {
             if ($fecha_inicio != $fecha_fin) {
                 $cal->setDateLink($fecha_inicio, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters);
                 $cal->setDateLink($fecha_fin, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters);
             } else {
                 $cal->setDateLink($fecha_inicio, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters);
             }
         } else {
             if ($fecha_inicio != $fecha_fin) {
                 $cal->setDateLink($fecha_inicio, "1");
                 $cal->setDateLink($fecha_fin, "1");
             } else {
                 $cal->setDateLink($fecha_inicio, "1");
             }
         }
//.........这里部分代码省略.........
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:101,代码来源:TareaPeer.php

示例11: testGetDay

 /**
  * @covers Geissler\Converter\Model\Date::getDay
  */
 public function testGetDay()
 {
     $this->assertInstanceOf($this->class, $this->object->setDay(19));
     $this->assertEquals(19, $this->object->getDay());
 }
开发者ID:avvertix,项目名称:converter,代码行数:8,代码来源:DateTest.php

示例12: Date

 /**
  * Compares the given date and the current date.
  *
  * @return integer
  * @link http://www.php.net/manual/en/function.mktime.php
  */
 function _compareGivenDateAndCurrentDate()
 {
     $givenDate = new Date();
     $givenDate->setYear($this->_year);
     $givenDate->setMonth($this->_month);
     $givenDate->setDay($this->_day);
     $givenDate->setHour(0);
     $givenDate->setMinute(0);
     $givenDate->setSecond(0);
     $currentDate = new Date();
     $currentDate->setHour(0);
     $currentDate->setMinute(0);
     $currentDate->setSecond(0);
     return @Date::compare($givenDate, $currentDate);
 }
开发者ID:nyarla,项目名称:fluxflex-rep2ex,代码行数:21,代码来源:Date.php

示例13: transferFinishedTransactions

function transferFinishedTransactions($account, $plannedTransaction)
{
    $now = new Date();
    $date = new Date($plannedTransaction->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 = $plannedTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
        $account->addFinishedTransaction($plannedTransaction->getAmount(), $plannedTransaction->getTitle(), $plannedTransaction->getDescription(), new Date($date), $plannedTransaction->getTransactionPartner(), $plannedTransaction->getCategory(), $plannedTransaction->getOutsideCapital(), false, true);
        //do the date calculation
        switch ($plannedTransaction->getRepeatUnit()) {
            case 'day':
                $date->addSeconds($plannedTransaction->getRepeatFrequency() * 24 * 60 * 60);
                break;
            case 'week':
                $date->addSeconds($plannedTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
                break;
            case 'month':
                //Set the month
                $date = new Date(Date_Calc::endOfMonthBySpan($plannedTransaction->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() + $plannedTransaction->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', $plannedTransaction->getRepeatUnit());
                exit;
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:badger-svn,代码行数:39,代码来源:Transaction.php

示例14: handle_month_recurrence

 /**
  * Specifically handle month recurrence
  *
  * This method will take care of parsing the month
  * recurrence data and correctly rescheduling a
  * scan if the recurrence time has been met
  *
  * @param array $parameters Array of the parameters
  *	from the database entry for this recurrence
  *	setting
  */
 private function handle_month_recurrence($parameters)
 {
     $the_interval = $parameters['the_interval'];
     $profile_id = $parameters['profile_id'];
     $date_scheduled = $parameters['date_scheduled'];
     $rules_string = $parameters['rules_string'];
     $specific_time = $this->specific_time($parameters['specific_time']);
     // The monthly rules string is colon delimited with a max of 3 items
     $tmp = explode(':', $rules_string);
     // The type of monthly recursion will be 'day' or 'gen'
     $type = $tmp[0];
     // This is either the day of the month, or a relative day of the week
     $day = $tmp[1];
     /**
      * Take the date the scan was scheduled, and only return the
      * year and month because my calculations are based off of the 0th
      * day of the month at midnight. Using 0th day because of how 
      * strtotime determines it's offset
      */
     $month_time = strtotime($date_scheduled);
     $month_time = strftime("%Y-%m-00 00:00:00", $month_time);
     /**
      * Get X months in the future from the last date scheduled
      * Because the remaining date calculations will be based
      * off of that future time.
      */
     $time = strtotime("+{$the_interval} month", strtotime($month_time));
     /**
      * Turn the future date into PEAR object so I can use
      * the PEAR object's methods.
      */
     $future_date = new Date($time);
     $future_month = $future_date->getMonth();
     $future_year = $future_date->getYear();
     switch ($type) {
         case "gen":
             // Get the weekday that was specified
             $weekday = $this->get_weekday_fullname($tmp[2]);
             // Get the number of days in the month
             $days_in_month = Date_Calc::daysInMonth($future_month, $future_year);
             /**
              * Turn the above into an array where the day of the
              * month is the value. The last value will be the last
              * day of the month
              */
             for ($day = 1; $day <= $days_in_month; $day++) {
                 $days[] = $day;
             }
             $days_in_month = $days;
             switch ($day) {
                 case "1st":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday);
                     $future_date->setDay($day);
                     break;
                 case "2nd":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 2);
                     $future_date->setDay($day);
                     break;
                 case "3rd":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 3);
                     $future_date->setDay($day);
                     break;
                 case "4th":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 4);
                     $future_date->setDay($day);
                     break;
                 case "last":
                     $days_in_month = array_reverse($days_in_month);
                     /**
                      * I reversed the array above, so in essence we're
                      * starting from the end of the month, therefore the
                      * "last" day of the month will, in this case, be
                      * the first match
                      */
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday);
                     $future_date->setDay($day);
                     break;
                 case "2_last":
                     $days_in_month = array_reverse($days_in_month);
                     /**
                      * I reversed the array above, so in essence we're
                      * starting from the end of the month, therefore the
                      * "2nd to last" day of the month will, in this case, be
                      * the second match
                      */
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 2);
                     $future_date->setDay($day);
                     break;
             }
//.........这里部分代码省略.........
开发者ID:TheProjecter,项目名称:nessquik,代码行数:101,代码来源:Cron.php

示例15: fillGapsAndLink

 /**
  * A method to fill an array of statistics data with any weeks, days, months, day
  * of weeks or hours of data that need to be included to make the statistics screen
  * "complete".
  *
  * Also ensures that any already set weeks, days, months, day of weeks or hours have
  * the correct formatting for display applied, and that the correct URI is used for
  * the week, day, month, day of week or hour column items.
  *
  * @param array $aStats   A reference to the array of statistics that needs to be filled.
  * @param array $aDates   An array of the days, months, days of week or hours that should
  *                        be filled in $aStats.
  * @param object $oCaller The calling object. Expected to have the the following class
  *                        variables set:
  *                                  $oCaller->statsBreakdown - The way stats are broken down
  *                                  $oCaller->aEmptyRow      - What an empty row looks like
  * @param string $link    Optional partial URL to be used for creating the link for the
  *                        week, day, month, day of week or hour column items.
  */
 function fillGapsAndLink(&$aStats, $aDates, $oCaller, $link = '')
 {
     foreach ($aDates as $key => $date_f) {
         // Ensure that all the required items are set by adding empty rows, if required.
         if (!isset($aStats[$key])) {
             $aStats[$key] = array($oCaller->statsBreakdown => $key) + $oCaller->aEmptyRow;
         }
         $aStats[$key]['date_f'] = $date_f;
         // Calculate CTR and other columns, making sure that the method is available
         if (is_callable(array($oCaller, '_summarizeStats'))) {
             $oCaller->_summarizeStats($aStats[$key]);
         }
         // Prepare the array of parameters for creating the LHC day-breakdown link,
         // if required - simply the $oCaller->aPageParams array with "entity" and
         // "breakdown" set as required
         if (!empty($link)) {
             $aDayLinkParams = array();
             $aDayLinkParams['entity'] = $oCaller->entity;
             $aDayLinkParams['breakdown'] = $oCaller->dayLinkBreakdown;
             $aDayLinkParams = array_merge($oCaller->aPageParams, $aDayLinkParams);
         }
         // Add links to the left hand column items, if required
         switch ($oCaller->statsBreakdown) {
             case 'week':
             case 'day':
                 // Set the "day/week" value
                 $oDate = new Date($key);
                 $aStats[$key]['day'] = $oDate->format($GLOBALS['date_format']);
                 if (!empty($link)) {
                     // Set LHC day-breakdown link, if required:
                     $aStats[$key]['link'] = $oCaller->_addPageParamsToURI($link, $aDayLinkParams) . 'day=' . str_replace('-', '', $key);
                     $aParams = $oCaller->_removeDuplicateParams($link);
                     $aStats[$key]['linkparams'] = substr($oCaller->_addPageParamsToURI('', $aParams) . 'day=' . str_replace('-', '', $key), 1);
                     $aStats[$key]['convlinkparams'] = substr($oCaller->_addPageParamsToURI('', $aParams) . 'day=' . str_replace('-', '', $key), 1);
                 }
                 break;
             case 'month':
                 // Set the "month" value
                 $oMonthStart = new Date(sprintf('%s-%02d', $key, 1));
                 $oMonthEnd = new Date();
                 $oMonthEnd->copy($oMonthStart);
                 $oMonthEnd->setDay($oMonthEnd->getDaysInMonth());
                 $aStats[$key]['month'] = $key;
                 if (!empty($link)) {
                     $aParams = $oCaller->_removeDuplicateParams($link);
                     $aStats[$key]['linkparams'] = substr($oCaller->_addPageParamsToURI('', $aParams) . 'period_preset=specific&' . 'period_start=' . $oMonthStart->format('%Y-%m-%d') . '&' . 'period_end=' . $oMonthEnd->format('%Y-%m-%d'), 1);
                     $aStats[$key]['convlinkparams'] = substr($oCaller->_addPageParamsToURI('', $aParams) . 'period_preset=specific&' . 'period_start=' . $oMonthStart->format('%Y-%m-%d') . '&' . 'period_end=' . $oMonthEnd->format('%Y-%m-%d'), 1);
                 }
                 break;
             case 'dow':
                 // Set the "dow" value
                 $aStats[$key]['dow'] = $key;
                 break;
             case 'hour':
                 // Set the "hour" value
                 $aStats[$key]['hour'] = $key;
                 if (!empty($link) && !empty($this->aDates['day_begin']) && !empty($this->aDates['day_end']) && $this->aDates['day_begin'] == $this->aDates['day_end']) {
                     $aParams = $oCaller->_removeDuplicateParams($link);
                     $aStats[$key]['linkparams'] = substr($oCaller->_addPageParamsToURI('', $aParams) . 'day=' . str_replace('-', '', $this->aDates['day_begin']) . '&' . 'hour=' . sprintf('%02d', $key), 1);
                     $aStats[$key]['convlinkparams'] = substr($oCaller->_addPageParamsToURI('', $aParams) . 'day=' . str_replace('-', '', $this->aDates['day_begin']) . '&' . 'hour=' . sprintf('%02d', $key), 1);
                 }
                 break;
         }
     }
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:84,代码来源:History.php


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