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


PHP Zend_Date::compare方法代码示例

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


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

示例1: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if a field name has been set, the field name is available in the
  * context, and the value of that field name matches the provided value.
  *
  * @param  string $value
  * @param array $context
  *
  * @return boolean
  */
 public function isValid($value, $context = null)
 {
     $this->_setValue($value);
     $fieldValue = $this->getFieldValue($context);
     if (null === $fieldValue) {
         return false;
     }
     $date = new Zend_Date($value, Zend_Date::ISO_8601);
     $date2 = new Zend_Date($fieldValue, Zend_Date::ISO_8601);
     if ($date->compare($date2) < 0 || !$this->_allowEqual && $date->compare($date2) == 0) {
         $this->_error(self::NOT_GREATER, $date2);
         return false;
     }
     return true;
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:26,代码来源:DateGreaterThanField.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: _beforeSave

 /**
  * Unset array element with '__empty' key
  *
  */
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (is_array($value)) {
         unset($value['__empty']);
     }
     $arr = array();
     foreach ($value as $key => $val) {
         if (isset($val['min_order_qty']) && isset($val['max_order_qty']) && isset($val['point_value_referrer']) && isset($val['calculation_type_referrer']) && isset($val['point_value_referred']) && isset($val['calculation_type_referred']) && isset($val['date_from']) && isset($val['date_end'])) {
             if (is_float($val['point_value_referrer']) && (int) $val['point_value_referrer'] != 0) {
                 Mage::getSingleton('adminhtml/session')->addError('Referrer Point/Ratio values issue. Value must be an integer.');
             }
             if (is_float($val['point_value_referred']) && (int) $val['point_value_referred'] != 0) {
                 Mage::getSingleton('adminhtml/session')->addError('Referred Point/Ratio values issue. Value must be an integer.');
             }
             $fromDate = $toDate = null;
             $data = $this->_filterDates($val, array('date_from', 'date_end'));
             $fromDate = $data['date_from'];
             $toDate = $data['date_end'];
             if ($fromDate && $toDate) {
                 $fromDate = new Zend_Date($fromDate, Varien_Date::DATE_INTERNAL_FORMAT);
                 $toDate = new Zend_Date($toDate, Varien_Date::DATE_INTERNAL_FORMAT);
                 if ($fromDate->compare($toDate) === 1) {
                     Mage::getSingleton('adminhtml/session')->addError('End Date must be greater than Start Date.');
                 }
             }
             $arr[$key] = $data;
         }
     }
     $this->setValue($arr);
     //$this->setValue($value);
     parent::_beforeSave();
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:37,代码来源:Arrayreferral.php

示例4: pruneOldBackups

 public function pruneOldBackups()
 {
     $current_bucket = Mage::getStoreConfig('system/cloudbackup/bucket_name');
     if (!$current_bucket) {
         $this->log("No bucket is set, we cannot prune old backups.");
         return;
     }
     $s3 = Mage::helper('cloudbackup')->getS3Client();
     try {
         $bucket_contents = $s3->getBucket($current_bucket);
         $cutoff_date = new Zend_Date();
         $cutoff_date->sub($this->NUM_MONTHS, Zend_Date::MONTH);
         foreach ($bucket_contents as $key) {
             $bucket_date = new Zend_Date($key['time'], Zend_Date::TIMESTAMP);
             if ($bucket_date->compare($cutoff_date) == -1) {
                 $this->log($key['name'] . " was created on {$bucket_date} and is older than " . $this->NUM_MONTHS . " months, deleting.");
                 $s3->deleteObject($current_bucket, $key['name']);
             }
         }
     } catch (Exception $e) {
         Mage::logException($e);
         $this->log("Failed to while pruning old backups - please see exception.log for details.");
         return;
     }
 }
开发者ID:rjocoleman,项目名称:Magento-Cloud-Backup,代码行数:25,代码来源:Backup.php

示例5: updateSpecificCoupons

 /**
  * Update auto generated Specific Coupon if it's rule changed
  *
  * @param Mage_SalesRule_Model_Rule $rule
  * @return Mage_SalesRule_Model_Resource_Coupon
  */
 public function updateSpecificCoupons(Mage_SalesRule_Model_Rule $rule)
 {
     if (!$rule || !$rule->getId() || !$rule->hasDataChanges()) {
         return $this;
     }
     $updateArray = array();
     if ($rule->dataHasChangedFor('uses_per_coupon')) {
         $updateArray['usage_limit'] = $rule->getUsesPerCoupon();
     }
     if ($rule->dataHasChangedFor('uses_per_customer')) {
         $updateArray['usage_per_customer'] = $rule->getUsesPerCustomer();
     }
     $ruleNewDate = new Zend_Date($rule->getToDate());
     $ruleOldDate = new Zend_Date($rule->getOrigData('to_date'));
     if ($ruleNewDate->compare($ruleOldDate)) {
         $updateArray['expiration_date'] = $rule->getToDate();
     }
     if (!empty($updateArray)) {
         $this->_getWriteAdapter()->update($this->getTable('salesrule/coupon'), $updateArray, array('rule_id = ?' => $rule->getId(), 'generated_by_dotmailer is null'));
     }
     //update coupons added by dotmailer. not to change expiration date
     $dotmailerUpdateArray = $updateArray;
     unset($dotmailerUpdateArray['expiration_date']);
     if (!empty($dotmailerUpdateArray)) {
         $this->_getWriteAdapter()->update($this->getTable('salesrule/coupon'), $dotmailerUpdateArray, array('rule_id = ?' => $rule->getId(), 'generated_by_dotmailer is 1'));
     }
     return $this;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento-extension,代码行数:34,代码来源:Coupon.php

示例6: _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 ($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'));
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:27,代码来源:Subscription.php

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

示例8: filterLs

 public function filterLs($lsResult, $io)
 {
     $_lsResult = array();
     foreach ($lsResult as $r) {
         if ($io->getUdbatchGrep() && !fnmatch($io->getUdbatchGrep(), $r['text']) || $io->isDir($r['text'])) {
             continue;
         }
         $_lsResult[] = $r;
     }
     $lsResult = $_lsResult;
     if ($io->getUdbatch() && ($dateFilter = $io->getUdbatch()->getDatetimeFilter())) {
         $filterFrom = null;
         if ('0000-00-00 00:00:00' != $dateFilter[0] && !empty($dateFilter[0])) {
             $filterFrom = new Zend_Date();
             $filterFrom->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
             $filterFrom->set($dateFilter[0], Varien_Date::DATETIME_INTERNAL_FORMAT);
             $filterFrom->setTimezone($dateFilter[2]);
         }
         $filterTo = null;
         if ('0000-00-00 00:00:00' != $dateFilter[1] && !empty($dateFilter[1])) {
             $filterTo = new Zend_Date();
             $filterTo->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
             $filterTo->set($dateFilter[1], Varien_Date::DATETIME_INTERNAL_FORMAT);
             $filterTo->setTimezone($dateFilter[2]);
         }
         $_lsResult = array();
         foreach ($lsResult as $r) {
             $filter = new Zend_Date();
             $filter->setTimezone($dateFilter[2]);
             $filter->set($io->mdtm($r['text']));
             if ((empty($filterFrom) || $filter->compare($filterFrom) >= 0) && (empty($filterTo) || $filter->compare($filterTo) == -1)) {
                 $_lsResult[] = $r;
             }
         }
         $lsResult = $_lsResult;
     }
     return $lsResult;
 }
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:38,代码来源:Io.php

示例9: isValid

 public function isValid($value, $context = null)
 {
     $value = (string) $value;
     $this->_setValue($value);
     if (isset($context)) {
         $date = new Zend_Date($value);
         $departureTime = new Zend_Date($context['departureTime']);
         if ($date->compare($departureTime) <= 0) {
             $this->_error(self::INVALID);
             return false;
         }
     }
     return true;
 }
开发者ID:rizkioa,项目名称:etak6,代码行数:14,代码来源:ArrivalTime.php

示例10: getMagentoCronStatusToHtml

 public function getMagentoCronStatusToHtml($fieldName = 'scheduled_at')
 {
     $scheduleCollection = Mage::getModel('cron/schedule')->getCollection();
     $scheduleCollection->setOrder($fieldName);
     $scheduleModel = $scheduleCollection->getFirstItem();
     $result = sprintf(self::ERROR_RESULT, $this->__('Never'));
     if ($scheduleModel->getId() && $scheduleModel->getData($fieldName) != '0000-00-00 00:00:00') {
         $findDate = new Zend_Date($scheduleModel->getData($fieldName), Varien_Date::DATETIME_INTERNAL_FORMAT);
         $today = new Zend_Date(null, Zend_Date::DATE_SHORT);
         $result = sprintf(self::SUCCESS_RESULT, $findDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
         if ($findDate->compare($today, Zend_Date::DATE_SHORT) < 0) {
             $result = sprintf(self::ERROR_RESULT, $findDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
         }
     }
     return $result;
 }
开发者ID:HPTTeam,项目名称:hackathon,代码行数:16,代码来源:Website.php

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

示例12: _checkPublished

 /**
  * Checks if content published
  *
  * @return bool true if published
  */
 private function _checkPublished()
 {
     if ($this->_container === null) {
         return true;
     }
     if (!$this->_container->getPublished()) {
         if ($this->_container->getPublishingDate()) {
             $zDate = new Zend_Date();
             $result = $zDate->compare(strtotime($this->_container->getPublishingDate()));
             if ($result == 0 || $result == 1) {
                 $this->_container->setPublishingDate('')->setPublished(true);
                 Application_Model_Mappers_ContainerMapper::getInstance()->save($this->_container);
             }
         }
     }
     return (bool) $this->_container->getPublished();
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:22,代码来源:Content.php

示例13: saveAction

 public function saveAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         try {
             $redirectBack = $this->getRequest()->getParam('back', false);
             if (!Mage::helper('points')->magentoLess14()) {
                 //_filterDates convert dates in array from localized to internal format only for magento > 1.4
                 $data = $this->_filterDates($data, array('from_date', 'to_date'));
                 if (isset($data['from_date']) && $data['from_date'] instanceof Zend_Date) {
                     $data['from_date'] = $data['from_date']->toString(VARIEN_DATE::DATE_INTERNAL_FORMAT);
                 }
                 if (isset($data['to_date']) && $data['to_date'] instanceof Zend_Date) {
                     $data['to_date'] = $data['to_date']->toString(VARIEN_DATE::DATE_INTERNAL_FORMAT);
                 }
             }
             if (!empty($data['from_date']) && !empty($data['to_date'])) {
                 $fromDate = new Zend_Date($data['from_date'], VARIEN_DATE::DATE_INTERNAL_FORMAT);
                 $toDate = new Zend_Date($data['to_date'], VARIEN_DATE::DATE_INTERNAL_FORMAT);
                 if ($fromDate->compare($toDate) === 1) {
                     throw new Exception($this->__("'To Date' must be equal or more than 'From Date'"));
                 }
             }
             $model = Mage::getModel('points/rule');
             $data['conditions'] = $data['rule']['conditions'];
             unset($data['rule']);
             $model->loadPost($data);
             if ($this->getRequest()->getParam('_save_as_flag')) {
                 $model->setId(null);
             }
             $model->save();
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('points')->__('Rule was successfully saved'));
             if ($redirectBack) {
                 $this->_redirect('*/*/edit', array('id' => $model->getId(), '_current' => true));
                 return;
             }
             return $this->_redirect('*/*/');
         } catch (Exception $e) {
             Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
             Mage::getSingleton('adminhtml/session')->setPageData($data);
             $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('rule_id')));
             return;
         }
     }
     $this->_redirect('*/*/');
 }
开发者ID:monarcmoso,项目名称:beta2,代码行数:45,代码来源:RuleController.php

示例14: validateAge

 public function validateAge($value)
 {
     $parts = @explode('-', $value);
     // Error if not filled out
     if (count($parts) < 3 || count(array_filter($parts)) < 3) {
         //$this->addError('Please fill in your birthday.');
         return false;
     }
     $value = mktime(0, 0, 0, $parts[1], $parts[2], $parts[0]);
     // Error if too low
     $date = new Zend_Date($value);
     $date->add((int) $this->min_age, Zend_Date::YEAR);
     if ($date->compare(new Zend_Date()) > 0) {
         //$this->addError('You are not old enough.');
         return false;
     }
     return true;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:18,代码来源:Birthdate.php

示例15: getIntervals

 public function getIntervals()
 {
     if (!$this->_intervals) {
         $this->_intervals = array();
         if (!$this->_from && !$this->_to) {
             return $this->_intervals;
         }
         $dateStart = new Zend_Date($this->_from);
         $dateStart2 = new Zend_Date($this->_from);
         $dateEnd = new Zend_Date($this->_to);
         $t = array();
         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'] = $dateStart->toString('yyyy-MM-01 00:00:00');
                     $t['end'] = $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                     $dateStart->addMonth(1);
                     break;
                 case 'year':
                     $t['title'] = $dateStart->toString('yyyy');
                     $t['start'] = $dateStart->toString('yyyy-01-01 00:00:00');
                     $t['end'] = $dateStart->toString('yyyy-12-31 23:59:59');
                     $dateStart->addYear(1);
                     break;
             }
             $this->_intervals[$t['title']] = $t;
         }
         if ($this->_period != 'day') {
             $titles = array_keys($this->_intervals);
             if (count($titles) > 0) {
                 $this->_intervals[$titles[0]]['start'] = $dateStart2->toString('yyyy-MM-dd 00:00:00');
                 $this->_intervals[$titles[count($titles) - 1]]['end'] = $dateEnd->toString('yyyy-MM-dd 23:59:59');
             }
         }
     }
     return $this->_intervals;
 }
开发者ID:joebushi,项目名称:magento-mirror,代码行数:44,代码来源:Collection.php


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