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


PHP Zend_Date::addDayOfYear方法代码示例

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


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

示例1: _addSarpInfo

 protected function _addSarpInfo($buyRequest, $product)
 {
     $Period = Mage::getModel('sarp/period');
     /* We should add custom options that doesnt exist */
     if ($buyRequest->getAwSarpSubscriptionType()) {
         if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
             $product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
         }
     }
     if (!is_null($buyRequest->getAwSarpSubscriptionStart()) && $Period->getId()) {
         $start = $buyRequest->getAwSarpSubscriptionStart();
         if (!empty($start)) {
             $date = new Zend_Date($start, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
         } else {
             $date = $Period->getNearestAvailableDay();
         }
         // Check date
         // Never check if start date
         //$performDateCompare = !!Mage::getSingleton('customer/session')->getCustomer()->getId();
         $performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
         $today = new Zend_Date();
         if (!$this->isVirtual($product)) {
             $today->addDayOfYear($Period->getPaymentOffset());
         }
         if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
             $date = $Period->getNearestAvailableDay();
         }
     } else {
         $date = Mage::app()->getLocale()->date();
     }
     $product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:32,代码来源:Subscription.php

示例2: _prepareProduct

 /**
  * Prepare product and its configuration to be added to some products list.
  * Perform standard preparation process and then add Configurable specific options.
  *
  * @param Varien_Object $buyRequest
  * @param Mage_Catalog_Model_Product $product
  * @param string $processMode
  * @return array|string
  */
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     if (!$product->getAwSarpEnabled()) {
         return;
     }
     Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
     $Period = Mage::getModel('sarp/period');
     /* We should add custom options that doesn't exist */
     if ($buyRequest->getAwSarpSubscriptionType()) {
         if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
             $product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
         }
     }
     if ((empty($options['aw_sarp_subscription_start']['month']) || empty($options['aw_sarp_subscription_start']['day']) || empty($options['aw_sarp_subscription_start']['year'])) && $buyRequest->getAwSarpSubscriptionType() != AW_Sarp_Model_Period::PERIOD_TYPE_NONE) {
         $date = new Zend_Date();
         $buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
     }
     if (isset($options['aw_sarp_subscription_start']) && is_array($options['aw_sarp_subscription_start']) && $buyRequest->getAwSarpSubscriptionType() != AW_Sarp_Model_Period::PERIOD_TYPE_NONE && !empty($options['aw_sarp_subscription_start']['month']) && !empty($options['aw_sarp_subscription_start']['day']) && !empty($options['aw_sarp_subscription_start']['year'])) {
         $subscriptionStart = $options['aw_sarp_subscription_start'];
         $date = new Zend_Date();
         $date->setMinute(0)->setHour(0)->setSecond(0)->setDay($subscriptionStart['day'])->setMonth($subscriptionStart['month'])->setYear($subscriptionStart['year']);
         $buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
     }
     if (!is_null($buyRequest->getAwSarpSubscriptionStart()) && $Period->getId()) {
         $start = $buyRequest->getAwSarpSubscriptionStart();
         if (!empty($start)) {
             $date = new Zend_Date($start, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
         } else {
             $date = $Period->getNearestAvailableDay();
         }
         $performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
         $today = new Zend_Date();
         if (!$this->isVirtual($product)) {
             $today->addDayOfYear($Period->getPaymentOffset());
         }
         if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
             $date = $Period->getNearestAvailableDay();
         }
     } else {
         $date = Mage::app()->getLocale()->date();
     }
     $product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
     $_result = parent::_prepareProduct($buyRequest, $product, $processMode);
     if (is_array($_result)) {
         if ($buyRequest->getAwSarpSubscriptionType()) {
             if ($Period->getId()) {
                 $_result[0]->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
                 $_result[0]->addCustomOption('aw_sarp_subscription_type', $Period->getId());
             }
         }
         return $_result;
     }
     return $this->getSpecifyOptionMessage();
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:63,代码来源:Subscription.php

示例3: testLoose


//.........这里部分代码省略.........
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
开发者ID:jsnshrmn,项目名称:Suma,代码行数:67,代码来源:DateTest.php

示例4: exorcise

 /**
  * Deletes all old log records
  *
  * @return AW_Core_Helper_Logger
  */
 public function exorcise()
 {
     $Date = new Zend_Date();
     Zend_Date::setOptions(array('extend_month' => true));
     $Date->addDayOfYear(0 - (int) Mage::getStoreConfig('awall/awcore/logger_store_days'));
     foreach (Mage::getModel('awcore/logger')->getCollection()->addOlderThanFilter($Date) as $entry) {
         $entry->delete();
     }
     return $this;
 }
开发者ID:monarcmoso,项目名称:beta2,代码行数:15,代码来源:Logger.php

示例5: _generateSubscriptionEvents

 /**
  * Generates events for purchasing to subscription
  * @return AW_Sarp_Model_Subscription
  */
 protected function _generateSubscriptionEvents()
 {
     // Delete all sequencies
     if ($this->_origData['date_start'] != $this->_data['date_start'] || $this->_origData['period_type'] != $this->_data['period_type'] || !$this->getIsNew() && $this->getIsReactivated()) {
         Mage::getResourceModel('sarp/sequence')->deleteBySubscriptionId($this->getId());
         $Date = new Zend_Date(strtotime($this->getDateStart()), Zend_Date::TIMESTAMP);
         Zend_Date::setOptions(array('extend_month' => true));
         // Fix Zend_Date::addMonth unexpected result
         switch ($this->getPeriod()->getPeriodType()) {
             case 'day':
                 $method = 'addDayOfYear';
                 break;
             case 'month':
                 $method = 'addMonth';
                 break;
             case 'week':
                 $method = 'addWeek';
                 break;
             case 'year':
                 $method = 'addYear';
                 break;
             default:
                 throw new Mage_Core_Exception("Unknown subscription period type for #" . $this->getPeriod()->getId());
         }
         switch ($this->getPeriod()->getExpireType()) {
             case 'day':
                 $method_expire = 'addDayOfYear';
                 break;
             case 'month':
                 $method_expire = 'addMonth';
                 break;
             case 'week':
                 $method_expire = 'addWeek';
                 break;
             case 'year':
                 $method_expire = 'addYear';
                 break;
             default:
                 throw new Mage_Core_Exception("Unknown subscription expire period type for #" . $this->getPeriod()->getId());
         }
         $ExpireDate = clone $Date;
         $expireMultiplier = $this->getPeriod()->getExpireValue();
         if (!$expireMultiplier) {
             // 0 means infinite expiration date
             $expireMultiplier = 3;
             // 0 means expire_method = method
             $method_expire = $method;
             $_Date = $this->getLastPaidDate();
             if (is_object($_Date)) {
                 $ExpireDate = clone $_Date;
             }
         }
         $ExpireDate = call_user_func(array($ExpireDate, $method_expire), $expireMultiplier);
         // Substract delivery offset. This is
         $Date->addDayOfYear(0 - $this->getPeriod()->getPaymentOffset());
         $ExpireDate->addDayOfYear(0 - $this->getPeriod()->getPaymentOffset());
         try {
             $this->getPeriod()->validate();
             while ($Date->compare($ExpireDate) == -1) {
                 $Date = call_user_func(array($Date, $method), $this->getPeriod()->getPeriodValue());
                 Mage::getModel('sarp/sequence')->setSubscriptionId($this->getId())->setDate($Date->toString(self::DB_DATE_FORMAT))->save();
             }
         } catch (AW_Sarp_Exception $e) {
             $this->log('Unable create sequences to subscription #' . $this->getId(), AW_Core_Model_Logger::LOG_SEVERITY_WARNING, 'Unable create sequences to subscription. Message: "' . $e->getMessage() . '"');
         }
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:72,代码来源:Subscription.php

示例6: prepareForCart

 /**
  * Prepares product for cart according to buyRequest.
  *
  * @param Varien_Object $buyRequest
  * @param object        $product [optional]
  * @return
  */
 public function prepareForCart(Varien_Object $buyRequest, $product = null, $old = false)
 {
     if (!$product->getAwSarpEnabled()) {
         if (!$old) {
             return parent::prepareForCart($buyRequest, $product);
         }
         return;
     }
     Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
     /*
      * For creating order from admin
      * If product is added to cart from admin, we doesn't add sart custom options to it.
      */
     $Period = Mage::getModel('sarp/period');
     if ($product->getAwSarpPeriod()) {
         if (count(explode(",", $product->getAwSarpPeriod())) === 1) {
             $date = Mage::getModel('sarp/period')->load($product->getAwSarpPeriod())->getNearestAvailableDay();
             $product->setAwSarpSubscriptionType($product->getAwSarpPeriod());
             $product->setAwSarpSubscriptionStart($date->toString(), Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
         }
     }
     /* We should add custom options that doesnt exist */
     if ($buyRequest->getAwSarpSubscriptionType()) {
         if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
             $product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
         }
     } else {
         if ($product->getAwSarpSubscriptionType()) {
             $buyRequest->setAwSarpSubscriptionType($product->getAwSarpSubscriptionType());
             $product->addCustomOption('aw_sarp_subscription_type', $product->getAwSarpSubscriptionType());
             $Period->setId($product->getAwSarpSubscriptionStart());
         }
     }
     if ($this->requiresSubscriptionOptions($product) && !$Period->getId()) {
         $date = Mage::app()->getLocale()->date();
     }
     $options = $buyRequest->getOptions();
     if (isset($options['aw_sarp_subscription_start']) && is_array($options['aw_sarp_subscription_start']) && !empty($options['aw_sarp_subscription_start']['day']) && !empty($options['aw_sarp_subscription_start']['month']) && !empty($options['aw_sarp_subscription_start']['year'])) {
         $subscriptionStart = $options['aw_sarp_subscription_start'];
         $date = new Zend_Date();
         $date->setMinute(0)->setHour(0)->setSecond(0)->setDay($subscriptionStart['day'])->setMonth($subscriptionStart['month'])->setYear($subscriptionStart['year']);
         $buyRequest->setAwSarpSubscriptionStart($date->toString(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
     }
     if (!is_null($buyRequest->getAwSarpSubscriptionStart()) && $Period->getId()) {
         $start = $buyRequest->getAwSarpSubscriptionStart();
         if (!empty($start)) {
             $date = new Zend_Date($start, Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
         } else {
             $date = $Period->getNearestAvailableDay();
         }
         // Check date
         // Never check if start date
         //$performDateCompare = !!Mage::getSingleton('customer/session')->getCustomer()->getId();
         $performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
         $today = new Zend_Date();
         if (!$this->isVirtual($product)) {
             $today->addDayOfYear($Period->getPaymentOffset());
         }
         if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
             $date = $Period->getNearestAvailableDay();
         }
     } else {
         $date = Mage::app()->getLocale()->date();
     }
     $product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
     if (!$old) {
         return parent::prepareForCart($buyRequest, $product);
     }
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:76,代码来源:Subscription.php

示例7: getNearestAvailableDay

 /**
  * Returns nearest available date starting from today
  * @return Zend_Date
  */
 public function getNearestAvailableDay()
 {
     $Date = new Zend_Date();
     Zend_Date::setOptions(array('extend_month' => true));
     $Date->addDayOfYear((int) $this->getPaymentOffset());
     $exclDays = $this->getExcludedWeekdays();
     Zend_Date::setOptions(array('extend_month' => true));
     // Fix Zend_Date::addMonth unexpected result
     if (count($exclDays) == 7) {
         return $Date->addYear(99);
     }
     while (!$this->isAllowedDate($Date)) {
         $Date = $Date->addDayOfYear(1);
     }
     return $Date;
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:20,代码来源:Period.php

示例8: prepareForCartAdvanced

 public function prepareForCartAdvanced(Varien_Object $buyRequest, $product = null, $processMode = null)
 {
     Mage::getModel('sarp/product_type_default')->checkPeriod($product, $buyRequest);
     $Period = Mage::getModel('sarp/period');
     /* We should add custom options that doesnt exist */
     if ($buyRequest->getAwSarpSubscriptionType()) {
         if ($Period->load($buyRequest->getAwSarpSubscriptionType())->getId()) {
             $product->addCustomOption('aw_sarp_subscription_type', $Period->getId());
         }
     }
     if ($this->requiresSubscriptionOptions($product) && !$Period->getId()) {
         throw new Mage_Core_Exception(Mage::helper('sarp')->__("Selected product requires subscription options"));
     }
     if ($buyRequest->getAwSarpSubscriptionStart() && $Period->getId()) {
         $date = new Zend_Date($buyRequest->getAwSarpSubscriptionStart(), Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
         // Check date
         // Never check if start date
         //$performDateCompare = !!Mage::getSingleton('customer/session')->getCustomer()->getId();
         $performDateCompare = !AW_Sarp_Model_Cron::$isCronSession;
         $today = new Zend_Date();
         if (!$this->isVirtual($product)) {
             $today->addDayOfYear($Period->getPaymentOffset());
         }
         if ($performDateCompare && ($date->compare($today, Zend_Date::DATE_SHORT) < 0 || !$Period->isAllowedDate($date, $product))) {
             throw new Mage_Core_Exception(Mage::helper('sarp')->__("Selected date is not valid for specified period"));
         }
     } else {
         $date = Mage::app()->getLocale()->date();
     }
     $product->addCustomOption('aw_sarp_subscription_start', $date->toString('Y-MM-dd'));
     $result = Mage_Catalog_Model_Product_Type_Virtual::prepareForCartAdvanced($buyRequest, $product);
     if (is_string($result)) {
         return $result;
     }
     $preparedLinks = array();
     if ($this->getProduct($product)->getLinksPurchasedSeparately()) {
         if ($links = $buyRequest->getLinks()) {
             foreach ($this->getLinks($product) as $link) {
                 if (in_array($link->getId(), $links)) {
                     $preparedLinks[] = $link->getId();
                 }
             }
         }
     } else {
         foreach ($this->getLinks($product) as $link) {
             $preparedLinks[] = $link->getId();
         }
     }
     if ($preparedLinks) {
         $this->getProduct($product)->addCustomOption('downloadable_link_ids', implode(',', $preparedLinks));
         return $result;
     }
     return $result;
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:54,代码来源:Subscription.php


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