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


PHP Zend_Date::setDay方法代码示例

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


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

示例1: getIntervals

 public function getIntervals()
 {
     if (!$this->_intervals) {
         $this->_intervals = array();
         if (!$this->_from && !$this->_to) {
             return $this->_intervals;
         }
         $dateStart = new Zend_Date($this->_from);
         $dateEnd = new Zend_Date($this->_to);
         $t = array();
         $firstInterval = true;
         /** START AITOC FIX **/
         if (in_array((string) $this->_period, array('day', 'month', 'year'))) {
             /** END AITOC FIX **/
             while ($dateStart->compare($dateEnd) <= 0) {
                 switch ($this->_period) {
                     case 'day':
                         $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                         $t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
                         $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
                         $dateStart->addDay(1);
                         break;
                     case 'month':
                         $t['title'] = $dateStart->toString('MM/yyyy');
                         $t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-MM-01 00:00:00');
                         $lastInterval = $dateStart->compareMonth($dateEnd->getMonth()) == 0;
                         $t['end'] = $lastInterval ? $dateStart->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                         $dateStart->addMonth(1);
                         if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
                             $dateStart->setDay(1);
                         }
                         $firstInterval = false;
                         break;
                     case 'year':
                         $t['title'] = $dateStart->toString('yyyy');
                         $t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-01-01 00:00:00');
                         $lastInterval = $dateStart->compareYear($dateEnd->getYear()) == 0;
                         $t['end'] = $lastInterval ? $dateStart->setMonth($dateEnd->getMonth())->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-12-31 23:59:59');
                         $dateStart->addYear(1);
                         if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
                             $dateStart->setMonth(1)->setDay(1);
                         }
                         $firstInterval = false;
                         break;
                 }
                 $this->_intervals[$t['title']] = $t;
             }
             /** START AITOC FIX **/
         }
         /** END AITOC FIX **/
     }
     return $this->_intervals;
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:53,代码来源:ReportsReportCollection.php

示例2: getTransactionList

 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $report = $this->_adsense->reports->generate($dStartDate->toString("YYYY-MM-dd"), $dEndDate->toString("YYYY-MM-dd"), array("dimension" => "DATE", "metric" => array("PAGE_VIEWS", "CLICKS", "EARNINGS"), "sort" => "DATE"));
     $firstDayMonth = new Zend_Date();
     $firstDayMonth->setDay(1);
     $firstDayMonth->setHour("00");
     $firstDayMonth->setMinute("00");
     $firstDayMonth->setSecond("00");
     if (isset($report["rows"])) {
         foreach ($report["rows"] as $row) {
             $obj = array();
             $obj['merchantId'] = 1;
             $tDate = new Zend_Date($row[0], "yyyy-MM-dd");
             $tDate->setHour("00");
             $tDate->setMinute("00");
             $tDate->setSecond("00");
             $obj['date'] = $tDate->toString("yyyy-MM-dd HH:mm:ss");
             $obj['impression_number'] = (int) Oara_Utilities::parseDouble($row[1]);
             $obj['click_number'] = Oara_Utilities::parseDouble($row[2]);
             if ($firstDayMonth->compare($tDate) <= 0) {
                 $obj['amount'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['commission'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['status'] = Oara_Utilities::STATUS_PENDING;
             } else {
                 $obj['amount'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['commission'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['status'] = Oara_Utilities::STATUS_CONFIRMED;
             }
             $totalTransactions[] = $obj;
         }
     }
     return $totalTransactions;
 }
开发者ID:netzkind,项目名称:php-oara,代码行数:38,代码来源:AdSense.php

示例3: indexAction

 /**
  * Enter description here...
  *
  */
 public function indexAction()
 {
     $currentDate = new Zend_Date();
     $currentMonth = $currentDate->toString(Zend_Date::MONTH_SHORT);
     $currentDay = $currentDate->toString(Zend_Date::DAY_SHORT);
     $month = $this->_getParam('month', $currentMonth);
     if (false === is_numeric($month)) {
         $month = $this->_monthMap[urldecode($month)];
     }
     $currentDate->setMonth($month);
     $currentDate->setDay(1);
     $days = $currentDate->toString(Zend_Date::MONTH_DAYS);
     $this->view->selectedMonth = $month;
     $this->view->currentMonth = $currentMonth;
     $this->view->currentDay = $currentDay;
     $result = Bc_UserDTO::fetchAsArray(array('month' => $month));
     $month = array();
     for ($i = 1; $i <= $days; $i++) {
         $data = array();
         $data['date'] = $currentDate->toString(Zend_Date::DAY . '.' . Zend_Date::MONTH . '.' . Zend_Date::YEAR);
         $user = array();
         foreach ($result as $birthday) {
             if ($i == $birthday['birthday']) {
                 $user[] = $birthday;
             }
         }
         $data['user'] = empty($user) ? null : $user;
         $month[$i] = $data;
         $currentDate->add('24:00:00', Zend_Date::TIMES);
     }
     $this->view->month = $month;
 }
开发者ID:noon,项目名称:phpMyBirthday,代码行数:36,代码来源:IndexController.php

示例4: testNetwork

 /**
  * Test the network provided
  * @param $affiliateNetwork
  * @return none
  */
 public static function testNetwork($network)
 {
     //Start date, the first two months ago
     $startDate = new Zend_Date();
     $startDate->setDay(1);
     $startDate->subMonth(2);
     $startDate->setHour(00);
     $startDate->setMinute(00);
     $startDate->setSecond(00);
     //Yesterday, some networks don't give us the data for the same day, then is the safer way to have our data
     $endDate = new Zend_Date();
     $endDate->subDay(1);
     $endDate->setHour(23);
     $endDate->setMinute(59);
     $endDate->setSecond(59);
     //are we connected?
     if ($network->checkConnection()) {
         //Get all the payments for this network.
         $paymentsList = $network->getPaymentHistory();
         echo "Total Number of payments: " . count($paymentsList) . "\n\n";
         //Get all the Merhcants
         $merchantList = $network->getMerchantList(array());
         echo "Number of merchants: " . count($merchantList) . "\n\n";
         // Building the array of merchant Id we want to retrieve data from.
         $merchantIdList = array();
         foreach ($merchantList as $merchant) {
             $merchantIdList[] = $merchant['cid'];
         }
         //If we have joined any merchant
         if (!empty($merchantIdList)) {
             //Split the dates monthly, Most of the network don't allow us to retrieve more than a month data
             $dateArray = Oara_Utilities::monthsOfDifference($startDate, $endDate);
             for ($i = 0; $i < count($dateArray); $i++) {
                 // Calculating the start and end date for the current month
                 $monthStartDate = clone $dateArray[$i];
                 $monthEndDate = null;
                 if ($i != count($dateArray) - 1) {
                     $monthEndDate = clone $dateArray[$i];
                     $monthEndDate->setDay(1);
                     $monthEndDate->addMonth(1);
                     $monthEndDate->subDay(1);
                 } else {
                     $monthEndDate = $endDate;
                 }
                 $monthEndDate->setHour(23);
                 $monthEndDate->setMinute(59);
                 $monthEndDate->setSecond(59);
                 echo "\n importing from " . $monthStartDate->toString("dd-MM-yyyy HH:mm:ss") . " to " . $monthEndDate->toString("dd-MM-yyyy HH:mm:ss") . "\n";
                 $transactionList = $network->getTransactionList($merchantIdList, $monthStartDate, $monthEndDate);
                 echo "Number of transactions: " . count($transactionList) . "\n\n";
                 $overviewList = $network->getOverviewList($transactionList, $merchantIdList, $monthStartDate, $monthEndDate);
                 echo "Number register on the overview: " . count($overviewList) . "\n\n";
             }
         }
         echo "Import finished \n\n";
     } else {
         echo "Error connecting to the network, check credentials\n\n";
     }
 }
开发者ID:robryanx,项目名称:php-oara,代码行数:64,代码来源:Test.php

示例5: myBest

 /**
  * Retrieve Bestseller product to show in frontend
  * @return mixed
  */
 public function myBest()
 {
     $storeId = Mage::app()->getStore()->getId();
     $HandleArray = Mage::app()->getLayout()->getUpdate()->getHandles();
     $CategoryHandle = 'catalog_category_view';
     $SourceConfig = Mage::getStoreConfig('sm_bestseller/sm_bestseller_source');
     if ($SourceConfig && !empty($SourceConfig)) {
         $SourceType = $SourceConfig['timeperiod'];
         $date = new Zend_Date();
         /**
          * Select time range to retrive bestseller
          */
         if ($SourceType && $SourceType == 'specify') {
             $fromDate = $date->setDate($SourceConfig['fromdate'])->get('Y-MM-dd');
             $toDate = $date->setDate($SourceConfig['todate'])->get('Y-MM-dd');
         } else {
             /**
              * use switch to return begin of week, month, year...
              */
             switch ($SourceType) {
                 case 'subWeek':
                     $toDate = $date->subDay($date->getDate()->get('e'))->getDate()->get('Y-MM-dd');
                     break;
                 case 'subMonth':
                     $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
                     break;
                 case 'subYear':
                     $toDate = $date->subDay($date->getDate()->get('D'))->getDate()->get('Y-MM-dd');
                     break;
                 default:
                     $toDate = $date->getDate()->get('Y-MM-dd');
             }
             // end switch
             $subType = $SourceType;
             $unit = $SourceConfig['unit'] ? $SourceConfig['unit'] : 1;
             $fromDate = $date->{$subType}($unit)->getDate()->get('Y-MM-dd');
         }
         // end else
         /**
          * Limit maximum product retrieve
          */
         $limit = $SourceConfig['limitproduct'];
         if ($limit > 0 && ctype_digit($limit)) {
             $this->setProductsCount($limit);
         }
         $products = Mage::getResourceModel('reports/product_collection')->addOrderedQty($fromDate, $toDate)->addAttributeToSelect('*')->addAttributeToSelect(array('name', 'price', 'small_image'))->setStoreId($storeId)->addStoreFilter($storeId)->setOrder('ordered_qty', 'desc');
         // most best sellers on top
         Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
         $products->setPageSize($limit)->setCurPage(1);
         if (in_array($CategoryHandle, $HandleArray)) {
             $CategoryId = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
             $CategoryModel = Mage::getModel('catalog/category')->load($CategoryId);
             $products->addCategoryFilter($CategoryModel);
         }
         return $products;
     }
     // end if sourceconfig
 }
开发者ID:luoi,项目名称:mockmagentosample,代码行数:63,代码来源:Bestseller.php

示例6: indexAction

 /**
  * 
  */
 public function indexAction()
 {
     $formSearch = new Fefop_Form_BankStatementSearch();
     $formSearch->setAction($this->_helper->url('list-statement'));
     $this->view->formSearch = $formSearch;
     $today = new Zend_Date();
     $today->setDay(1)->subDay(1);
     $this->view->lastMonth = $today;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:12,代码来源:BankStatementController.php

示例7: toZendDateTime

 /**
  * @return Zend_Date
  * เปลี่ยนวันที่ในรูปแบบ dd/mm/yyyy   เป็น object DateTime
  */
 static function toZendDateTime($stringDateTime, $dateType = 'AD', $delimiter = '/')
 {
     //echo "toDateTime". $stringDateTime;
     $dates = explode($delimiter, $stringDateTime);
     $year = $dates[2];
     $month = $dates[1];
     $day = $dates[0];
     $date = new Zend_Date();
     $date->setDay($day)->setMonth($month)->setYear($year);
     return $date;
 }
开发者ID:hugi2002,项目名称:mylibrary,代码行数:15,代码来源:Util.php

示例8: indexAction

 /**
  * 
  */
 public function indexAction()
 {
     $form = $this->_getForm($this->_helper->url('save'));
     // Get items to consolidate
     $itemsToConsolidate = $this->_mapper->listExpensesToConsolidate();
     $this->view->items = $itemsToConsolidate;
     $this->view->form = $form;
     $today = new Zend_Date();
     $today->setDay(1)->subDay(1);
     $this->view->lastMonth = $today;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:14,代码来源:BankConsolidateController.php

示例9: getBestsellerProducts

 public function getBestsellerProducts()
 {
     $storeId = (int) Mage::app()->getStore()->getId();
     // Date
     $date = new Zend_Date();
     $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
     $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
     $collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addStoreFilter()->setPageSize(6);
     $collection->getSelect()->joinLeft(array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
     return $collection;
 }
开发者ID:vlikin,项目名称:test_magento_skin,代码行数:13,代码来源:Bestsold.php

示例10: getLoadedProductCollection

 public function getLoadedProductCollection()
 {
     if ($this->getRequest()->getParam('id') != null) {
         $id = $this->getRequest()->getParam('id');
         // benchmarking
         $memory = memory_get_usage();
         $time = microtime();
         $catId = $id;
         /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
         $collection = Mage::getResourceModel('catalog/product_collection');
         // join sales order items column and count sold products
         $expression = new Zend_Db_Expr("SUM(oi.qty_ordered)");
         $condition = new Zend_Db_Expr("e.entity_id = oi.product_id AND oi.parent_item_id IS NULL");
         $collection->addAttributeToSelect('*')->getSelect()->join(array('oi' => $collection->getTable('sales/order_item')), $condition, array('sales_count' => $expression))->group('e.entity_id')->order('sales_count' . ' ' . 'desc');
         // join category
         $condition = new Zend_Db_Expr("e.entity_id = ccp.product_id");
         $condition2 = new Zend_Db_Expr("c.entity_id = ccp.category_id");
         $collection->getSelect()->join(array('ccp' => $collection->getTable('catalog/category_product')), $condition, array())->join(array('c' => $collection->getTable('catalog/category')), $condition2, array('cat_id' => 'c.entity_id'));
         $condition = new Zend_Db_Expr("c.entity_id = cv.entity_id AND ea.attribute_id = cv.attribute_id");
         // cutting corners here by hardcoding 3 as Category Entiry_type_id
         $condition2 = new Zend_Db_Expr("ea.entity_type_id = 3 AND ea.attribute_code = 'name'");
         $collection->getSelect()->join(array('ea' => $collection->getTable('eav/attribute')), $condition2, array())->join(array('cv' => $collection->getTable('catalog/category') . '_varchar'), $condition, array('cat_name' => 'cv.value'));
         // if Category filter is on
         if ($catId) {
             $collection->getSelect()->where('c.entity_id = ?', $catId)->limit(20);
         }
         // unfortunately I cound not come up with the sql query that could grab only 1 bestseller for each category
         // so all sorting work lays on php
         $result = array();
         foreach ($collection as $product) {
             /** @var $product Mage_Catalog_Model_Product */
             if (isset($result[$product->getCatId()])) {
                 continue;
             }
             $result[$product->getCatId()] = 'Category:' . $product->getCatName() . '; Product:' . $product->getName() . '; Sold Times:' . $product->getSalesCount();
         }
     } else {
         $id = 2;
         $storeId = (int) Mage::app()->getStore()->getId();
         // Date
         $date = new Zend_Date();
         $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
         $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
         $collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addStoreFilter()->addPriceData()->addTaxPercents()->addUrlRewrite()->setPageSize(6);
         $collection->getSelect()->joinLeft(array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'))->limit(5);
         Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
     }
     return $collection;
 }
开发者ID:santhosh400,项目名称:ecart,代码行数:50,代码来源:Seller.php

示例11: monthAction

 public function monthAction()
 {
     // param handling
     $year = $this->_getParam('year');
     $month = $this->_getParam('month');
     if (!$year or !$month) {
         throw new Exception('');
     }
     // start & stop date
     $startDate = new Zend_Date($year . '-' . $month . '-01', 'yyyy-M-dd');
     $stopDate = new Zend_Date($startDate);
     $stopDate->addMonth(1)->addDay(-1);
     // spacings (start & end)
     $startSpace = $startDate->get(Zend_Date::WEEKDAY_8601) - 1;
     $stopSpace = 7 - $stopDate->get(Zend_Date::WEEKDAY_8601);
     // arrays
     $calendar = array();
     $week = array();
     for ($startSpace; $startSpace >= 1; $startSpace--) {
         $spaceDate = new Zend_Date($startDate);
         $spaceDate->addDay(-$startSpace);
         $day = array('date' => $spaceDate);
         $week[] = $day;
     }
     for ($currentDay = 1; $currentDay <= $stopDate->get('d'); $currentDay++) {
         $currentDate = new Zend_Date($startDate);
         $currentDate->setDay($currentDay);
         $day = array('date' => $currentDate);
         $week[] = $day;
         if (count($week) / 7 == 1) {
             $calendar[] = array('info' => $currentDate, 'columns' => $week);
             $week = array();
         }
     }
     for ($stopSpace; $stopSpace >= 1; $stopSpace--) {
         $spaceDate = new Zend_Date($stopDate);
         $spaceDate->addDay(-$stopSpace);
         $day = array('date' => $spaceDate);
         $week[] = $day;
         if (count($week) / 7 == 1) {
             $calendar[] = array('info' => $currentDate, 'columns' => $week);
             $week = array();
         }
     }
     // view
     $this->view->rows = $calendar;
 }
开发者ID:jaspermeijaard,项目名称:home-booking-system,代码行数:47,代码来源:CalendarController.php

示例12: getListByDate

 /**
  * @param string $year
  * @param string $month
  * @param integer $page
  * @param integer $perPage
  * @return Zend_Paginator
  */
 public function getListByDate($year, $month = null, $page = 1, $perPage = 10)
 {
     $month = (int) $month;
     if ($month < 1 || $month > 12) {
         $month = 0;
         $date = new Zend_Date("{$year}-01-01", Zend_Date::ISO_8601);
     } else {
         if (1 == strlen($month)) {
             $month = "0{$month}";
         }
         $date = new Zend_Date("{$year}-{$month}-01", Zend_Date::ISO_8601);
     }
     $from = (int) $date->getTimestamp();
     if ($month) {
         $to = (int) $date->setDay($date->get(Zend_Date::MONTH_DAYS))->getTimestamp();
     } else {
         $to = (int) $date->setMonth(12)->setDay(31)->getTimestamp();
     }
     $list = $this->_getList();
     $list->setCondition('date BETWEEN ? AND ?', array($from, $to));
     return $this->_paginate($list, $page, $perPage);
 }
开发者ID:Cube-Solutions,项目名称:blog,代码行数:29,代码来源:Blog.php

示例13: testLoose


//.........这里部分代码省略.........
         // success
     }
     try {
         $date->compareYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
开发者ID:jsnshrmn,项目名称:Suma,代码行数:67,代码来源:DateTest.php

示例14: getCalendar

 public function getCalendar($month = null, $year = null, $location = null)
 {
     $zd = new Zend_Date();
     if (is_null($month)) {
         $month = date('n');
     }
     if (is_null($year)) {
         $year = date('Y');
     }
     $zd->setMonth($month);
     $zd->setYear($year);
     $zd->setDay(1);
     $calData = array();
     $calData['startDay'] = $zd->get(Zend_Date::WEEKDAY_DIGIT);
     $calData['month'] = $zd->get(Zend_Date::MONTH_SHORT);
     $calData['monthName'] = $zd->get(Zend_Date::MONTH_NAME);
     $calData['monthDays'] = $zd->get(Zend_Date::MONTH_DAYS);
     $calData['year'] = $zd->get(Zend_Date::YEAR);
     if ($calData['month'] == 12) {
         $calData['nextMonth'] = 1;
     } else {
         $calData['nextMonth'] = $calData['month'] + 1;
     }
     $calData['nextYear'] = $calData['year'];
     if ($calData['nextMonth'] == 1) {
         $calData['nextYear'] = $calData['year'] + 1;
     }
     if ($calData['month'] == 1) {
         $calData['prevMonth'] = 12;
     } else {
         $calData['prevMonth'] = $calData['month'] - 1;
     }
     $calData['prevYear'] = $calData['year'];
     if ($calData['prevMonth'] == 12) {
         $calData['prevYear'] = $calData['year'] - 1;
     }
     $tmpDate = new Zend_Date();
     $calData['week'] = $tmpDate->get(Zend_Date::WEEK);
     $calData['rows'] = array();
     $dayCounter = 1;
     // make sure we don't have an empty row
     if ($calData['startDay'] > 4) {
         $numRows = intval($calData['monthDays'] / 5);
     } else {
         $numRows = intval($calData['monthDays'] / 6);
     }
     for ($x = 0; $x < $numRows; $x++) {
         $sd = 0;
         if ($x == 0) {
             // this sets the first row to start on the correct day of the week
             for ($y = 0; $y < $calData['startDay']; $y++) {
                 $tmp = array();
                 $tmp['num'] = "";
                 $calData['rows'][$x]['days'][$y] = $tmp;
             }
             $sd = $calData['startDay'];
         }
         $event = new Event();
         // put the numbers in the rows
         for ($z = $sd; $z < 7; $z++) {
             $tmp = array();
             if ($dayCounter <= $calData['monthDays']) {
                 $zd->setDay($dayCounter);
                 // set the week number
                 $calData['rows'][$x]['weekNum'] = $zd->get(Zend_Date::WEEK);
                 $calData['rows'][$x]['weekYear'] = $zd->get(Zend_Date::YEAR);
                 if (isset($calData['rows'][$x - 1]['weekNum'])) {
                     if ($calData['rows'][$x - 1]['weekNum'] == 52) {
                         $calData['rows'][$x]['weekNum'] = "01";
                         $calData['rows'][$x]['weekYear'] = $year + 1;
                     }
                 }
                 $tmp['num'] = $dayCounter;
                 $calData['rows'][$x]['days'][$z] = $tmp;
                 $where = $event->getAdapter()->quoteInto('date = ?', $year . "-" . $month . "-" . $dayCounter);
                 $where .= " AND ";
                 $where .= $event->getAdapter()->quoteInto('status = ?', 'open');
                 if (!is_null($locationId)) {
                     $where .= " AND ";
                     $where .= $event->getAdapter()->quoteInto('locationId = ?', $locationId);
                 }
                 $events = $event->fetchAll($where, 'startTime')->toArray();
                 $calData['rows'][$x]['days'][$z]['numEvents'] = count($events);
             } else {
                 $tmp['num'] = "";
                 $calData['rows'][$x]['days'][$z] = $tmp;
             }
             $dayCounter++;
         }
     }
     return $calData;
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:92,代码来源:Calendar.php

示例15: testDay

 /**
  * test setting dates to specify weekdays
  */
 public function testDay()
 {
     // all tests and calculations below are in GMT (that is intention for this test)
     $date = new Zend_Date(0, 'de_AT');
     $date->setTimeZone('UTC');
     $dw = $date->getDay();
     $this->assertSame($dw->toString(), '01.01.1970 00:00:00');
     for ($day = 1; $day < 31; $day++) {
         $date->setDay($day);
         $dw = $date->getDay();
         $weekday = str_pad($day, 2, '0', STR_PAD_LEFT);
         $this->assertSame($dw->toString(), "{$weekday}.01.1970 00:00:00");
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:17,代码来源:DateTest.php


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