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


PHP Zend_Date::setDate方法代码示例

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


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

示例1: _filterSql

 protected function _filterSql()
 {
     $date = new Zend_Date();
     if (isset($this->filterdata['created_by']) && !empty($this->filterdata['created_by'])) {
         $this->_select->where("p.created_by = (?)", new Zend_Db_Expr("SELECT id FROM public.user WHERE upper(login) ilike '" . strtoupper($this->filterdata['created_by'] . "'")));
     }
     if (isset($this->filterdata['name']) && !empty($this->filterdata['name'])) {
         $this->_select->where("p.name ilike ?", $this->filterdata['name']);
     }
     if (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for'])) {
         $this->filterdata['date_for'] = $date->setDate($this->filterdata['date_for'], 'YYYY-MM-dd')->toString(Zend_Date::ISO_8601);
     }
     if (isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
         $this->filterdata['date_to'] = $date->setDate($this->filterdata['date_to'], 'YYYY-MM-dd')->toString(Zend_Date::ISO_8601);
     }
     if (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for']) && isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
         $this->_select->where('created_at BETWEEN \'' . $this->filterdata['date_for'] . '\' AND \'' . $this->filterdata['date_to'] . '\'');
     } elseif (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for'])) {
         $this->_select->where('created_at > ?', $this->filterdata['date_for']);
     } elseif (isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
         $this->_select->where('created_at < ?', $this->filterdata['date_to']);
     }
     if (isset($this->filterdata['ws_service_set_id']) && !empty($this->filterdata['ws_service_set_id'])) {
         $this->_select->where("ws_service_set_id = ?", $this->filterdata['ws_service_set_id']);
     }
     if (isset($this->filterdata['ws_service_group_id']) && !empty($this->filterdata['ws_service_group_id'])) {
         $this->_select->where("ws_service_group_id = ?", $this->filterdata['ws_service_group_id']);
     }
 }
开发者ID:knatorski,项目名称:SMS,代码行数:29,代码来源:Search.php

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

示例3: downloadAction

 public function downloadAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout->disableLayout();
     $request = $this->getRequest();
     $start = $this->_helper->IdConvert->hexToStr($request->getParam('date_for'));
     $end = $this->_helper->IdConvert->hexToStr($request->getParam('date_to'));
     $date = new Zend_Date();
     if (empty($start) || empty($end) || (!$date->setDate($start, "YYYY-MM-dd")->isDate($start, "YYYY-MM-dd") || !$date->setDate($end, "YYYY-MM-dd")->isDate($end, "YYYY-MM-dd"))) {
         $this->_helper->messenger()->error("Nie podano zakresu dat");
         return $this->_helper->redirector('index');
     }
     $logic = new Logic_Raports_Render($start, $end, $this->_helper->currentip());
     $logic->render();
 }
开发者ID:knatorski,项目名称:SMS,代码行数:15,代码来源:RaportsController.php

示例4: listAvisos

 /**
  * 
  */
 public function listAvisos($curso)
 {
     try {
         $auth = Zend_Auth::getInstance();
         $parameters = array('usuario' => $auth->getIdentity()->codigo, 'curso' => $curso);
         // Cria hash de comunicacao
         $parameters['hash'] = App_Util_Cenbrap::getHash($parameters, array('usuario', 'curso'));
         // Faz requisição para API
         $response = App_Util_Cenbrap::request('MuralAvisos', $parameters);
         if (empty($response['status'])) {
             throw new Exception('Erro ao listar mural de avisos');
         }
         $avisos = array();
         $date = new Zend_Date();
         foreach ($response['avisos'] as $aviso) {
             if (!empty($aviso['data'])) {
                 $date->setDate($aviso['data'], 'dd/MM/yyyy');
                 $avisos[$date->toString('yyyy-MM-dd')][] = $aviso;
             }
         }
         ksort($avisos);
         $avisos = array_reverse($avisos);
         return $avisos;
     } catch (Exception $e) {
         $this->_message->addMessage($e->getMessage(), App_Message::WARNING);
         return array();
     }
 }
开发者ID:fredcido,项目名称:cenbrap,代码行数:31,代码来源:Aviso.php

示例5: save

 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $dataForm['client'] = array_keys($this->_data['cost_client']);
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $dataForm, Fefop_Model_Mapper_Expense::CONFIG_PFPCI_FP);
         // If there is no contract yet
         if (empty($this->_data['fk_id_fefop_contract'])) {
             $dataContract = array('module' => Fefop_Model_Mapper_Module::FP, 'district' => $this->_data['fk_id_adddistrict']);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $this->_data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $date = new Zend_Date();
         $this->_data['date_start'] = $date->setDate($this->_data['start_date'])->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $date->setDate($this->_data['finish_date'])->toString('yyyy-MM-dd');
         $dataForm = $this->_data;
         // Save the contract
         $dataForm['id_fp_contract'] = parent::_simpleSave();
         // Set the class to the Planning Course
         $dbPlanningCourse = App_Model_DbTable_Factory::get('FPPlanningCourse');
         $row = $dbPlanningCourse->fetchRow(array('id_planning_course = ?' => $dataForm['fk_id_planning_course']));
         $row->fk_id_fefpstudentclass = $dataForm['fk_id_fefpstudentclass'];
         $row->save();
         // Save budget category
         $this->_saveBudgetCategory($dataForm);
         // Save the contract beneficiaries
         $this->_saveBeneficiaries($dataForm);
         if (empty($this->_data['id_fp_contract'])) {
             $history = 'REJISTU KONTRAKTU: %s BA ANNUAL PLANNING: %s';
         } else {
             $history = 'ATUALIZA KONTRAKTU: %s BA ANNUAL PLANNING: %s';
         }
         $history = sprintf($history, $dataForm['id_fp_contract'], $this->_data['fk_id_annual_planning']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $dataForm['id_fp_contract'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:50,代码来源:FPContract.php

示例6: indexAction

 public function indexAction()
 {
     $raportsModel = new Raports();
     $request = $this->getRequest();
     $hash = $request->getParam('hash');
     if (empty($hash)) {
         return;
     }
     $raport = $raportsModel->getRaportByHash($hash);
     if ($raport === null) {
         return;
     }
     $start = $raport->date_for;
     $end = $raport->date_to;
     $date = new Zend_Date();
     if (empty($start) || empty($end) || (!$date->setDate($start, "YYYY-MM-dd")->isDate($start, "YYYY-MM-dd") || !$date->setDate($end, "YYYY-MM-dd")->isDate($end, "YYYY-MM-dd"))) {
         return;
     }
     $logic = new Logic_Raports_Render($start, $end, $this->_helper->currentip());
     $logic->render();
 }
开发者ID:knatorski,项目名称:SMS,代码行数:21,代码来源:RaportsdownloadController.php

示例7: isValid

 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     if (!empty($data['date_for']) && !empty($data['date_to'])) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date->setDate($data['date_for'], 'YYYY-MM-dd')->getTimestamp();
         $date2->setDate($data['date_to'], 'YYYY-MM-dd')->getTimestamp();
         if ($date->isLater($date2)) {
             $isValid = false;
             $this->getElement('date_to')->addError("Data do nie może być wcześniejsza niż data od");
         }
     }
     return $isValid;
 }
开发者ID:knatorski,项目名称:SMS,代码行数:15,代码来源:Search.php

示例8: baseInit

 public function baseInit()
 {
     $this->datee(false, 'date_for', "Data od:", true);
     $this->date_for->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date->setDate($value, 'YYYY-MM-dd');
         return $date->isEarlier(new Zend_date()) || $date->isToday();
     }, 'messages' => array(Zend_Validate_Callback::INVALID_VALUE => "Data od nie może być datą przyszłą")));
     $this->datee(false, 'date_to', "Data do:", true);
     $this->date_to->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date->setDate($value, 'YYYY-MM-dd');
         return $date->isEarlier(new Zend_date()) || $date->isToday();
     }, 'messages' => array(Zend_Validate_Callback::INVALID_VALUE => "Data do nie może być datą przyszłą")));
     $this->submit(false, 'create_raport', 'Generuj raport');
 }
开发者ID:knatorski,项目名称:SMS,代码行数:16,代码来源:Search.php

示例9: getPredefinedStartDate

 public function getPredefinedStartDate()
 {
     $_editableOptions = $this->getProduct()->getPreconfiguredValues();
     if (isset($_editableOptions['aw_sarp_subscription_start'])) {
         $date = $_editableOptions['aw_sarp_subscription_start'];
         $zDate = new Zend_Date();
         $zDate->setDate($date);
         $today = new Zend_Date();
         $period = Mage::getModel('sarp/period')->load($_editableOptions['aw_sarp_subscription_type']);
         if ($zDate->compare($today, Zend_Date::DATE_SHORT) < 0 || !$period->isAllowedDate($zDate, $this->getProduct())) {
             $zDate = $period->getNearestAvailableDay();
         }
         $date = $zDate->toString(preg_replace(array('/M+/', '/d+/'), array('MM', 'dd'), Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
         return $date;
     }
     return null;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:17,代码来源:Downloadable.php

示例10: _afterSave

 protected function _afterSave(Mage_Core_Model_Abstract $object)
 {
     //insert field values
     if (count($object->getData('field')) > 0) {
         foreach ($object->getData('field') as $field_id => $value) {
             if (is_array($value)) {
                 $value = implode("\n", $value);
             }
             $field = Mage::getModel('webforms/fields')->load($field_id);
             if (strstr($field->getType(), 'date') && strlen($value) > 0) {
                 $date = new Zend_Date();
                 $date->setDate($value, $field->getDateFormat(), Mage::app()->getLocale()->getLocaleCode());
                 if ($field->getType() == 'datetime') {
                     $date->setTime($value, $field->getDateFormat(), Mage::app()->getLocale()->getLocaleCode());
                 }
                 $value = date($field->getDbDateFormat(), $date->getTimestamp());
             }
             if ($field->getType() == 'select/contact' && is_numeric($value)) {
                 $value = $field->getContactValueById($value);
             }
             if ($value == $field->getHint()) {
                 $value = '';
             }
             // create key
             $key = "";
             if ($field->getType() == 'file' || $field->getType() == 'image') {
                 $key = Mage::helper('webforms')->randomAlphaNum(6);
                 if ($object->getData('key_' . $field_id)) {
                     $key = $object->getData('key_' . $field_id);
                 }
             }
             $object->setData('key_' . $field_id, $key);
             $select = $this->_getReadAdapter()->select()->from($this->getTable('webforms/results_values'))->where('result_id = ?', $object->getId())->where('field_id = ?', $field_id);
             $result_value = $this->_getReadAdapter()->fetchAll($select);
             if (!empty($result_value[0])) {
                 $this->_getWriteAdapter()->update($this->getTable('webforms/results_values'), array("value" => $value, "key" => $key), "id = " . $result_value[0]['id']);
             } else {
                 $this->_getWriteAdapter()->insert($this->getTable('webforms/results_values'), array("result_id" => $object->getId(), "field_id" => $field_id, "value" => $value, "key" => $key));
             }
         }
     }
     Mage::dispatchEvent('webforms_result_save', array('result' => $object));
     return parent::_afterSave($object);
 }
开发者ID:monarcmoso,项目名称:beta2,代码行数:44,代码来源:Results.php

示例11: testSetDateWithArray

 /**
  * @ZF-7589
  */
 public function testSetDateWithArray()
 {
     $date = new Zend_Date(1234567890);
     $result = $date->setDate(array('year' => 2009, 'month' => 8, 'day' => 14));
     $this->assertSame('2009-08-14T04:31:30+05:00', $result->get(Zend_Date::W3C));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:9,代码来源:DateTest.php

示例12: _afterSave


//.........这里部分代码省略.........
                         // save default
                         $connection->insert($tablePrefix . 'catalog_product_option_type_price', array('option_type_id' => $optionTypeId, 'store_id' => 0, 'price' => $value['price'], 'price_type' => $value['price_type']));
                         $optionTypePriceId = $connection->lastInsertId($tablePrefix . 'catalog_product_option_type_price');
                     }
                     if (isset($value['title'])) {
                         // save default
                         $connection->insert($tablePrefix . 'catalog_product_option_type_title', array('option_type_id' => $optionTypeId, 'store_id' => 0, 'title' => $value['title']));
                     }
                     if (isset($value['description']) && $value['description'] != '') {
                         // save default
                         $connection->insert($tablePrefix . 'custom_options_option_type_description', array('option_type_id' => $optionTypeId, 'store_id' => 0, 'description' => $value['description']));
                     }
                 }
                 if ($optionTypeId > 0 && $optionTypePriceId >= 0) {
                     $id = $this->getData('id');
                     $this->_uploadImage('file_' . $id . '_' . $key, $optionId, $optionTypeId, $value);
                     // check $optionTypePriceId
                     if ($optionTypePriceId == 0) {
                         $select = $connection->select()->from($tablePrefix . 'catalog_product_option_type_price', array('option_type_price_id'))->where('option_type_id = ' . $optionTypeId . ' AND `store_id` = ' . $storeId);
                         $optionTypePriceId = $isUpdate = $connection->fetchOne($select);
                     }
                     if ($optionTypePriceId) {
                         // save special prices
                         if (isset($value['specials']) && is_array($value['specials'])) {
                             $specials = array();
                             foreach ($value['specials'] as $special) {
                                 if ($special['is_delete'] == '1' || isset($specials[$special['customer_group_id']])) {
                                     if ($special['special_price_id'] > 0) {
                                         $connection->delete($tablePrefix . 'custom_options_option_type_special_price', 'option_type_special_price_id = ' . intval($special['special_price_id']));
                                     }
                                     continue;
                                 }
                                 $specials[$special['customer_group_id']] = $special;
                             }
                             if (count($specials) > 0) {
                                 foreach ($specials as $special) {
                                     $zendDate = new Zend_Date();
                                     $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
                                     if ($special['date_from']) {
                                         $special['date_from'] = $zendDate->setDate($special['date_from'], $dateFormat)->toString(Varien_Date::DATE_INTERNAL_FORMAT);
                                     } else {
                                         $special['date_from'] = null;
                                     }
                                     if ($special['date_to']) {
                                         $special['date_to'] = $zendDate->setDate($special['date_to'], $dateFormat)->toString(Varien_Date::DATE_INTERNAL_FORMAT);
                                     } else {
                                         $special['date_to'] = null;
                                     }
                                     $specialData = array('option_type_price_id' => $optionTypePriceId, 'customer_group_id' => $special['customer_group_id'], 'price' => floatval($special['price']), 'price_type' => $special['price_type'], 'comment' => trim($special['comment']), 'date_from' => $special['date_from'], 'date_to' => $special['date_to']);
                                     if ($special['special_price_id'] > 0) {
                                         $connection->update($tablePrefix . 'custom_options_option_type_special_price', $specialData, 'option_type_special_price_id = ' . intval($special['special_price_id']));
                                     } else {
                                         $connection->insert($tablePrefix . 'custom_options_option_type_special_price', $specialData);
                                     }
                                 }
                             }
                         }
                         // save tier prices
                         if (isset($value['tiers']) && is_array($value['tiers'])) {
                             $tiers = array();
                             foreach ($value['tiers'] as $tier) {
                                 $uniqKey = $tier['qty'] . '+' . $tier['customer_group_id'];
                                 if ($tier['is_delete'] == '1' || isset($tiers[$uniqKey])) {
                                     if ($tier['tier_price_id'] > 0) {
                                         $connection->delete($tablePrefix . 'custom_options_option_type_tier_price', 'option_type_tier_price_id = ' . intval($tier['tier_price_id']));
                                     }
                                     continue;
                                 }
                                 $tiers[$uniqKey] = $tier;
                             }
                             if (count($tiers) > 0) {
                                 foreach ($tiers as $tier) {
                                     $tierData = array('option_type_price_id' => $optionTypePriceId, 'customer_group_id' => $tier['customer_group_id'], 'qty' => intval($tier['qty']), 'price' => floatval($tier['price']), 'price_type' => $tier['price_type']);
                                     if ($tier['tier_price_id'] > 0) {
                                         $connection->update($tablePrefix . 'custom_options_option_type_tier_price', $tierData, 'option_type_tier_price_id = ' . intval($tier['tier_price_id']));
                                     } else {
                                         $connection->insert($tablePrefix . 'custom_options_option_type_tier_price', $tierData);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 unset($value['option_type_id']);
             }
             $values[$key] = $value;
         }
         $this->setData('values', $values);
     } elseif ($this->getGroupByType($this->getType()) == self::OPTION_GROUP_SELECT) {
         Mage::throwException(Mage::helper('catalog')->__('Select type options required values rows.'));
     }
     if (version_compare($helper->getMagetoVersion(), '1.4.0', '>=')) {
         $this->cleanModelCache();
     }
     Mage::dispatchEvent('model_save_after', array('object' => $this));
     if (version_compare($helper->getMagetoVersion(), '1.4.0', '>=')) {
         Mage::dispatchEvent($this->_eventPrefix . '_save_after', $this->_getEventData());
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:cupboardglasspipes.ecomitize.com,代码行数:101,代码来源:Option.php

示例13: testSetDate

 /**
  * Test for setDate
  */
 public function testSetDate()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1234567890, null, $locale);
     $d2 = new Zend_Date(1234567899, null, $locale);
     $result = $date->setDate(Zend_Date::now());
     $this->assertTrue($result instanceof Zend_Date);
     $result = $date->setDate('11.05.2008');
     $this->assertSame($result->get(Zend_Date::W3C), '2008-04-11T00:31:30+02:00');
     $this->assertSame($date->get(Zend_Date::W3C), '2008-04-11T00:31:30+02:00');
     $date->setDate('2008-05-11', 'YYYY-MM-dd');
     $this->assertSame($date->get(Zend_Date::W3C), '2008-04-11T00:31:30+02:00');
     $date->setDate($d2);
     $this->assertSame($date->get(Zend_Date::W3C), '2009-02-14T00:31:30+01:00');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:DateTest.php

示例14: testLoose

 /**
  * test looseBehaviour
  */
 public function testLoose()
 {
     $date = new Zend_Date(0, 'de');
     try {
         $date->set(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->set(10, 'de');
     $this->assertEquals($date->getTimestamp(), 10);
     try {
         $date->add(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->add(10, 'de');
     $this->assertEquals($date->getTimestamp(), 20);
     try {
         $date->sub(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->sub(10, 'de');
     $this->assertEquals($date->getTimestamp(), 10);
     try {
         $date->compare(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->equals(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isEarlier(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isLater(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
//.........这里部分代码省略.........
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:DateTest.php

示例15: getPredefinedRange

 /**
  * 取得某个预定义时间段
  * 
  * @static
  * @param integer $interval
  * @param string $forceUnit
  * @param integer $timestamp
  * @return array
  */
 public static function getPredefinedRange($interval, $forceUnit = null, $timestamp = null)
 {
     if (empty($timestamp)) {
         $timestamp = time();
     }
     $start = new Zend_Date($timestamp);
     $end = new Zend_Date($timestamp);
     switch ($interval) {
         case self::TODAY:
             $start->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::HOUR;
             break;
         case self::YESTODAY:
             $start->subDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::TOMORROW:
             $start->addDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::THIS_MONTH:
             $start->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_YEAR:
             $start->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end->addMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_SEASON:
             $start->setMonth(3 * floor(($start->toValue('M') - 1) / 3) + 1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
         case self::RECENT_24HOUR:
             $start->subHour(24);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_48HOUR:
             $start->subHour(48);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_1WEEK:
             $start->subWeek(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_1MONTH:
             $start->subMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_24MONTH:
             $start->subMonth(24);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1MONTH:
             $start->subMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1YEAR:
             $start->subYear(1)->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addYear(1);
             $unit = Zend_Date::DAY;
             break;
         case self::ENTIRE_DAY:
             $start->setDate(self::ERA_DATE, self::ZF_DATE_FORMAT)->setTime(self::ERA_TIME, self::ZF_TIME_FORMAT);
             $end->addDay(1);
             $unit = Zend_Date::DAY;
             break;
         default:
             $unit = Zend_Date::SECOND;
     }
     if (!empty($forceUnit)) {
         $unit = $forceUnit;
     }
     $start = max(self::truncateDatetime($start, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     $end = max(self::truncateDatetime($end, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     return compact('start', 'end', 'unit');
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:92,代码来源:Datetime.php


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