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


PHP Zend_Date::setTime方法代码示例

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


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

示例1: getSavedTime

 public function getSavedTime()
 {
     $seconds = intval(Mage::helper('asyncindex')->getVariable('time'));
     $time = new Zend_Date();
     $time->setTime('00:00:00');
     $time->addSecond($seconds);
     return $time->toString('HH') . ' hr ' . $time->toString('mm') . ' min ' . $time->toString('ss') . ' sec';
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:8,代码来源:AsyncControl.php

示例2: weeklystatsAction

 public function weeklystatsAction()
 {
     $this->disableLayout();
     $this->disableViewAutoRender();
     $type = $this->getParam('type');
     $end = new Zend_Date();
     $end->setTime('23:59:59');
     $date = new Zend_Date();
     $date->sub(6, Zend_Date::DAY);
     $date->setTime('00:00:01');
     //Build reference array
     $i = 0;
     //echo $end->getTimestamp(); echo "<br>";
     while ($i <= 6) {
         $referencearray[$date->get('dd-MM-YYYY')] = 0;
         $date->add(1, Zend_Date::DAY);
         $i++;
     }
     //Get the results array
     $start = new Zend_date();
     $start->sub(6, Zend_Date::DAY);
     $start->setTime('00:00:01');
     $stat = new \Object\Stats();
     $results = $stat->getStatistics($this->selectedLocation->getId(), $start, $end);
     $startoftheweek = $start->get('dd-MM-YYYY');
     //echo $start->getTimestamp(); echo "<br>";exit;
     foreach ($this->selectedLocation->getServings() as $serving) {
         //initiate orderarray and seatsarray
         $orderarray = $referencearray;
         $seatsarray = $referencearray;
         foreach ($results as $result) {
             $datein = date("d-m-Y", $result["date_start"]);
             if ($serving->getId() == $result['serving_id']) {
                 $servingid = $result['serving_id'];
                 if (array_key_exists($datein, $referencearray)) {
                     $orderarray[$datein] = $result["nbre"];
                     $seatsarray[$datein] = $result["couverts"];
                 }
             }
         }
         if ($type == 'seats') {
             $servingarray[$serving->getTitle()] = $seatsarray;
         } else {
             $servingarray[$serving->getTitle()] = $orderarray;
         }
     }
     $reponse = new Reponse();
     $reponse->data = $servingarray;
     $reponse->message = "TXT_STATS_SENT";
     $reponse->success = true;
     $this->render($reponse);
 }
开发者ID:sgabison,项目名称:resaExpress,代码行数:52,代码来源:StatsController.php

示例3: portalAction

    public function portalAction()
    {
        $this->view->location = $this->selectedLocation;
        $servings = $this->selectedLocation->getServings();
        $this->view->count = count($servings);
        $start = new Zend_Date();
        $start->setTime("00:01:00");
        $end = new Zend_Date();
        $end->setTime("23:59:59");
        $this->view->reporttodaydata = $this->selectedLocation->getResource()->getRapportReservations($start, $end);
        $start->addDay(1);
        $end->addDay(1);
        $this->view->reporttomorrowdata = $this->selectedLocation->getResource()->getRapportReservations($start, $end);
        $this->view->servingarray = $servingarray;
        foreach ($servings as $serving) {
            $array['nbre'] = 0;
            $array['couverts'] = 0;
            $array['name'] = $serving->getTitle();
            foreach ($this->view->reporttodaydata as $report) {
                if ($report['serving_id'] == $serving->getId()) {
                    $array['nbre'] = $report['nbre'];
                    $array['couverts'] = $report['couverts'];
                }
            }
            $resulttoday[$serving->getId()] = $array;
        }
        $this->view->todayreport = $resulttoday;
        foreach ($servings as $serving) {
            $array['nbre'] = 0;
            $array['couverts'] = 0;
            $array['name'] = $serving->getTitle();
            foreach ($this->view->reporttomorrowdata as $report) {
                if ($report['serving_id'] == $serving->getId()) {
                    $array['nbre'] = $report['nbre'];
                    $array['couverts'] = $report['couverts'];
                }
            }
            $resulttomorrow[$serving->getId()] = $array;
        }
        $this->view->tomorrowreport = $resulttomorrow;
        $this->layout()->setLayout('portal');
        $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/plugins/jquery.sparkline/jquery.sparkline.js');
        $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/js/timepicker-form-elements.js');
        $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/js/index.js');
        $this->view->headScript()->appendFile(PIMCORE_WEBSITE_LAYOUTS . '/assets/js/stats.js');
        $this->view->inlineScript()->appendScript('jQuery(document).ready(function() { 
					Main.init();
					StatisticsForm.init();
					Index.init();
				});', 'text/javascript', array('noescape' => true));
        // Disable CDATA comments
    }
开发者ID:sgabison,项目名称:website,代码行数:52,代码来源:BookingController.php

示例4: getTotal

 public function getTotal($type, $start = null, $end = null)
 {
     $select = new Zend_Db_Select($this->getAdapter());
     $select->from($this->info('name'), 'SUM(value) as sum')->where('type = ?', $type);
     // Can pass "today" into start
     $date = new Zend_Date();
     $date->setTimezone(Engine_Api::_()->getApi('settings', 'core')->getSetting('core_locale_timezone', 'GMT'));
     switch ($start) {
         case 'day':
             $start = $date->setTime('00:00:00')->toValue();
             // mktime(0, 0, 0, gmdate("n"), gmdate("j"), gmdate("Y"));
             $end = $date->setTime('23:59:59')->toValue();
             // mktime(0, 0, 0, gmdate("n"), gmdate("j") + 1, gmdate("Y"));
             break;
         case 'week':
             $start = $date->setTime('00:00:00')->setWeekday(0)->toValue();
             // mktime(0, 0, 0, gmdate("n"), gmdate("j") - gmdate('N') + 1, gmdate("Y"));
             $end = $date->setTime('23:59:59')->toValue();
             // mktime(0, 0, 0, gmdate("n"), gmdate("j") - gmdate('N') + 1 + 7, gmdate("Y"));
             break;
         case 'month':
             $start = $date->setTime('00:00:00')->setDate(1)->toValue();
             // mktime(0, 0, 0, gmdate("n"), gmdate("j"), gmdate("Y"));
             $end = $date->setTime('23:59:59')->toValue();
             // mktime(0, 0, 0, gmdate("n") + 1, gmdate("j"), gmdate("Y"));
             break;
         case 'year':
             $start = $date->setTime('00:00:00')->setDayOfYear(1)->toValue();
             // mktime(0, 0, 0, gmdate("n"), gmdate("j"), gmdate("Y"));
             $end = $date->setTime('23:59:59')->toValue();
             // mktime(0, 0, 0, gmdate("n"), gmdate("j"), gmdate("Y") + 1);
             break;
     }
     if (null !== $start) {
         $select->where('date >= ?', gmdate('Y-m-d H:i:s', $start));
     }
     if (null !== $end) {
         $select->where('date < ?', gmdate('Y-m-d H:i:s', $end));
     }
     $data = $select->query()->fetch();
     if (!isset($data['sum'])) {
         return 0;
     }
     return $data['sum'];
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:45,代码来源:Statistics.php

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

示例6: testPhpFormatWithToString

 public function testPhpFormatWithToString()
 {
     Zend_Date::setOptions(array('format_type' => 'php'));
     $date = new Zend_Date('10.10.2009 10:10:10');
     $this->assertEquals('10.10.2009 10:10:10', $date->toString("d.m.Y H:i:s"));
     $date->setTime("23:59:59");
     $this->assertEquals('10.10.2009 23:59:59', $date->toString("d.m.Y H:i:s"));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:8,代码来源:DateTest.php

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

示例8: testSetTime

 /**
  * Test for setTime
  */
 public function testSetTime()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1234567890, null, $locale);
     $d2 = new Zend_Date(1234567899, null, $locale);
     $result = $date->setTime(Zend_Date::now());
     $this->assertTrue($result instanceof Zend_Date);
     $result = $date->setTime('10:20:30');
     $this->assertSame($result->get(Zend_Date::W3C), '2009-02-14T10:20:30+01:00');
     $this->assertSame($date->get(Zend_Date::W3C), '2009-02-14T10:20:30+01:00');
     $date->setTime('30-20-10', 'ss:mm:HH');
     $this->assertSame($date->get(Zend_Date::W3C), '2009-02-14T10:20:30+01:00');
     $date->setTime($d2);
     $this->assertSame($date->get(Zend_Date::W3C), '2009-02-14T00:31:39+01:00');
     $date = new Zend_Date(Zend_Date::now(), $locale);
     $t1 = $date->get(Zend_Date::TIMESTAMP);
     $date->setTime(Zend_Date::now());
     $t2 = $date->get(Zend_Date::TIMESTAMP);
     $diff = abs($t2 - $t1);
     $this->assertTrue($diff < 2, "Instance of Zend_Date has a significantly different time than returned by setTime(): {$diff} seconds");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:24,代码来源:DateTest.php

示例9: mapDirectiveSalePriceEffectiveDate

 protected function mapDirectiveSalePriceEffectiveDate($params = array())
 {
     $map = $params['map'];
     $product = $this->getProduct();
     /* @var $product Mage_Catalog_Model_Product */
     $cell = "";
     if (!$this->hasSpecialPrice()) {
         return $cell;
     }
     $cDate = Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     $timezone = Mage::app()->getStore($this->getStoreId())->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
     $fromDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     if ($timezone) {
         $fromDate->setTimezone($timezone);
     }
     $fromDate->setDate(substr($product->getSpecialFromDate(), 0, 10), 'yyyy-MM-dd');
     $fromDate->setTime(substr($product->getSpecialFromDate(), 11, 8), 'HH:mm:ss');
     $toDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     if (!is_empty_date($product->getSpecialToDate())) {
         if ($timezone) {
             $toDate->setTimezone($timezone);
         }
         $toDate->setDate(substr($product->getSpecialToDate(), 0, 10), 'yyyy-MM-dd');
         $toDate->setTime('23:59:59', 'HH:mm:ss');
     } else {
         if ($timezone) {
             $toDate->setTimezone($timezone);
         }
         $toDate->setDate($cDate->toString('yyyy-MM-dd'), 'yyyy-MM-dd');
         $toDate->setTime('23:59:59', 'HH:mm:ss');
         $toDate->add(7, Zend_Date::DAY);
     }
     $cell = $fromDate->toString(Zend_Date::ISO_8601) . "/" . $toDate->toString(Zend_Date::ISO_8601);
     return $cell;
 }
开发者ID:xiaoguizhidao,项目名称:beut,代码行数:35,代码来源:Abstract.php

示例10: mapDirectiveSalePriceEffectiveDate

 protected function mapDirectiveSalePriceEffectiveDate($params = array())
 {
     /** @var $product Mage_Catalog_Model_Product */
     $product = $this->getProduct();
     $assocMapArr = $this->getAssocMaps();
     $cDate = Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     $timezone = Mage::app()->getStore($this->getStoreId())->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
     $cell = "";
     if (!$this->hasSpecialPrice($product, $this->getSpecialPrice($product))) {
         return $cell;
     }
     $has_default_qty = $this->_hasDefaultQty($assocMapArr);
     $display_min = $this->getConfigVar('grouped_price_display_mode', 'columns');
     if ($has_default_qty) {
         if ($display_min == RocketWeb_GoogleBaseFeedGenerator_Model_Source_Pricegroupedmode::PRICE_SUM_DEFAULT_QTY) {
             $product_from_date = $product_to_date = null;
             $from_time = -1;
             $to_time = PHP_INT_MAX;
             foreach ($assocMapArr as $assocMap) {
                 $associatedProduct = $assocMap->getProduct();
                 if ($associatedProduct->getQty() > 0) {
                     if ($assocMap->hasSpecialPrice($associatedProduct, $assocMap->getSpecialPrice($associatedProduct))) {
                         if ($assocMap->hasPriceByCatalogRules($associatedProduct)) {
                             // Current date to cdate + ttl
                             $fromDate = clone $cDate;
                             $fromDate->setTime('00:00:00', 'HH:mm:ss');
                             $toDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
                             if ($timezone) {
                                 $toDate->setTimezone($timezone);
                             }
                             $toDate->setDate($cDate->toString('yyyy-MM-dd'), 'yyyy-MM-dd');
                             $toDate->setTime('23:59:59', 'HH:mm:ss');
                             $toDate->add((int) $this->getConfigVar('ttl', 'columns'), Zend_Date::DAY);
                             $compare_from_date = $fromDate->toString('yyyy-MM-dd 00:00:00');
                             $compare_to_date = $toDate->toString('yyyy-MM-dd 23:59:59');
                         } else {
                             $compare_from_date = $associatedProduct->getSpecialFromDate();
                             $compare_to_date = $associatedProduct->getSpecialToDate();
                         }
                         if ($from_time < $this->dateToTime($compare_from_date)) {
                             $product_from_date = $compare_from_date;
                             $from_time = $this->dateToTime($product_from_date);
                         }
                         if (!is_empty_date($compare_to_date) && $to_time > $this->dateToTime($compare_to_date)) {
                             $product_to_date = $compare_to_date;
                             $to_time = $this->dateToTime($product_to_date);
                         }
                     }
                 }
             }
         } else {
             // RocketWeb_GoogleBaseFeedGenerator_Model_Source_Pricegroupedmode::PRICE_START_AT
             $minAssocMap = $this->findMinimalPriceProduct($assocMapArr);
             if ($minAssocMap === false) {
                 return $cell;
             }
             $associatedProduct = $minAssocMap->getProduct();
             if ($minAssocMap->hasPriceByCatalogRules($associatedProduct)) {
                 // Current date to cdate + ttl
                 $fromDate = clone $cDate;
                 $fromDate->setTime('00:00:00', 'HH:mm:ss');
                 $toDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
                 if ($timezone) {
                     $toDate->setTimezone($timezone);
                 }
                 $toDate->setDate($cDate->toString('yyyy-MM-dd'), 'yyyy-MM-dd');
                 $toDate->setTime('23:59:59', 'HH:mm:ss');
                 $toDate->add((int) $this->getConfigVar('ttl', 'columns'), Zend_Date::DAY);
                 $compare_from_date = $fromDate->toString('yyyy-MM-dd 00:00:00');
                 $compare_to_date = $toDate->toString('yyyy-MM-dd 23:59:59');
             } else {
                 $compare_from_date = $associatedProduct->getSpecialFromDate();
                 $compare_to_date = $associatedProduct->getSpecialToDate();
             }
             $product_from_date = $compare_from_date;
             $product_to_date = $compare_to_date;
         }
     } else {
         // RocketWeb_GoogleBaseFeedGenerator_Model_Source_Pricegroupedmode::PRICE_START_AT
         $minAssocMap = $this->findMinimalPriceProduct($assocMapArr);
         if ($minAssocMap === false) {
             return $cell;
         }
         $associatedProduct = $minAssocMap->getProduct();
         $product_from_date = $associatedProduct->getSpecialFromDate();
         $product_to_date = $associatedProduct->getSpecialToDate();
     }
     $fromDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     if ($timezone) {
         $fromDate->setTimezone($timezone);
     }
     if ($product_from_date) {
         $fromDate->setDate(substr($product_from_date, 0, 10), 'yyyy-MM-dd');
         $fromDate->setTime(substr($product_from_date, 11, 8), 'HH:mm:ss');
     }
     $toDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     if (!is_empty_date($product_to_date)) {
         if ($timezone) {
             $toDate->setTimezone($timezone);
         }
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:101,代码来源:Grouped.php

示例11: toTimestamp

 public function toTimestamp($date, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
 {
     $dateFormat = Mage::app()->getLocale()->getDateFormat($format);
     $dateObj = new Zend_Date();
     if ($date) {
         try {
             $dateObj->setDate($date, $dateFormat);
         } catch (Exception $ex) {
             try {
                 $dateObj->setDate($date);
             } catch (Exception $ex) {
                 if ($timestamp = @strtotime($date)) {
                     $dateObj->setTimestamp($timestamp);
                 }
             }
         }
         $dateObj->setTime(0);
     }
     return $dateObj->getTimestamp();
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:20,代码来源:Date.php

示例12: chartSentHour

 /**
  * 
  * @param array $filters
  * @return array
  */
 public function chartSentHour(array $filters = array())
 {
     $date = new Zend_Date();
     // Set the date to search the current month
     $filters['date_ini'] = $date->toString('yyyy-MM-dd');
     $filters['date_fin'] = $date->toString('yyyy-MM-dd');
     // Set the hour to search
     $filters['hour_ini'] = $date->setTime('00:00:00')->toString('HH:mm:ss');
     $filters['hour_fin'] = $date->setTime('23:59:59')->toString('HH:mm:ss');
     // Search just the sending successfully
     $filters['status'] = 'S';
     $sent = $this->sentByHours($filters);
     // Search the erros with errors
     $filters['status'] = 'E';
     $errors = $this->sentByHours($filters);
     $hours = array();
     foreach ($sent as $row) {
         $hours[] = $row->hour;
     }
     foreach ($errors as $row) {
         $hours[] = $row->hour;
     }
     $hours = array_fill_keys(array_unique($hours), array('errors' => 0, 'sent' => 0));
     foreach ($sent as $row) {
         $hours[$row->hour]['sent'] = $row->sent;
     }
     foreach ($errors as $row) {
         $hours[$row->hour]['errors'] = $row->sent;
     }
     $data = array('hours' => array_keys($hours), 'errors' => array(), 'sent' => array());
     foreach ($hours as $row) {
         $data['errors'][] = (int) $row['errors'];
         $data['sent'][] = (int) $row['sent'];
     }
     return $data;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:41,代码来源:Campaign.php

示例13: getInterval

 /**
  * Return interval (two GMT Zend_Date).
  *
  * @param $code
  * @param bool $timezone
  *
  * @return Varien_Object
  */
 public function getInterval($code, $timezone = false)
 {
     $timestamp = Mage::getSingleton('core/date')->gmtTimestamp();
     if ($timezone) {
         $timestamp = Mage::app()->getLocale()->date($timestamp);
     }
     $from = new Zend_Date($timestamp, null, Mage::app()->getLocale()->getLocaleCode());
     $to = clone $from;
     $dateInterval = null;
     switch ($code) {
         case self::TODAY:
             $from->setTime('00:00:00');
             $to->setTime('23:59:59');
             break;
         case self::YESTERDAY:
             $from->subDay(1)->setTime('00:00:00');
             $to->subDay(1)->setTime('23:59:59');
             break;
         case self::THIS_MONTH:
             $from->setDay(1)->setTime('00:00:00');
             $to->setDay(1)->addDay($to->get(Zend_Date::MONTH_DAYS) - 1)->setTime('23:59:59');
             break;
         case self::PREVIOUS_MONTH:
             $from->setDay(1)->subMonth(1)->setTime('00:00:00');
             $to->setDay(1)->setTime('23:59:59')->subMonth(1)->addDay($to->get(Zend_Date::MONTH_DAYS) - 1);
             break;
         case self::THIS_QUARTER:
             $month = intval($from->get(Zend_Date::MONTH) / 4) * 3 + 1;
             $from->setDay(1)->setMonth($month)->setTime('00:00:00');
             $to->setDay(1)->setMonth($month)->addMonth(3)->subDay(1)->setTime('23:59:59');
             break;
         case self::PREVIOUS_QUARTER:
             $month = intval($from->get(Zend_Date::MONTH) / 4) * 3 + 1;
             $from->setDay(1)->setMonth($month)->setTime('00:00:00')->subMonth(3);
             $to->setDay(1)->setMonth($month)->addMonth(3)->subDay(1)->setTime('23:59:59')->subMonth(3);
             break;
         case self::THIS_YEAR:
             $from->setDay(1)->setMonth(1)->setTime('00:00:00');
             $to->setDay(1)->setMonth(1)->addDay($to->get(Zend_Date::LEAPYEAR) ? 365 : 364)->setTime('23:59:59');
             break;
         case self::PREVIOUS_YEAR:
             $from->setDay(1)->setMonth(1)->setTime('00:00:00')->subYear(1);
             $to->setDay(1)->setMonth(1)->addDay($to->get(Zend_Date::LEAPYEAR) ? 365 : 364)->setTime('23:59:59')->subYear(1);
             break;
         case self::LAST_24H:
             $from->subDay(1);
             break;
         case self::THIS_WEEK:
             $weekday = $from->get(Zend_Date::WEEKDAY_DIGIT);
             #0-6
             $from->setTime('00:00:00')->subDay($weekday);
             $to->setTime('23:59:59')->addDay(6 - $weekday);
             break;
         case self::PREVIOUS_WEEK:
             $weekday = $from->get(Zend_Date::WEEKDAY_DIGIT);
             #0-6
             $from->setTime('00:00:00')->subDay($weekday)->subWeek(1);
             $to->setTime('23:59:59')->addDay(6 - $weekday)->subWeek(1);
             break;
         case self::LAST_7D:
             $from->subDay(7);
             break;
         case self::LAST_30D:
             $from->subDay(30);
             break;
         case self::LAST_3M:
             $from->subMonth(3);
             break;
         case self::LAST_12M:
             $from->subYear(1);
             break;
         case self::LIFETIME:
             $from->subYear(10);
             $to->addYear(10);
             break;
     }
     return new Varien_Object(array('from' => $from, 'to' => $to));
 }
开发者ID:cesarfelip3,项目名称:clevermage_new,代码行数:86,代码来源:Report.php

示例14: hasSpecialPrice

 /**
  * @param $product
  * @param $special_price
  * @param $rules
  * @return bool
  */
 public function hasSpecialPrice($product, $special_price, $rules = true)
 {
     if ($rules && $this->hasPriceByCatalogRules($product)) {
         return true;
     }
     if ($special_price <= 0) {
         return false;
     }
     $cDate = Mage::app()->getLocale()->date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     $timezone = Mage::app()->getStore($this->getStoreId())->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
     // From Date
     $fromDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     if ($timezone) {
         $fromDate->setTimezone($timezone);
     }
     $special_from_date = $product->getSpecialFromDate();
     if (is_empty_date($special_from_date)) {
         $special_from_date = $cDate->toString('yyyy-MM-dd HH:mm:ss');
     }
     $fromDate->setDate(substr($special_from_date, 0, 10), 'yyyy-MM-dd');
     $fromDate->setTime(substr($special_from_date, 11, 8), 'HH:mm:ss');
     // To Date
     $toDate = new Zend_Date(null, null, Mage::app()->getLocale()->getDefaultLocale());
     if ($timezone) {
         $toDate->setTimezone($timezone);
     }
     $special_to_date = $product->getSpecialToDate();
     if (is_empty_date($special_to_date)) {
         $special_to_date = $cDate->toString('yyyy-MM-dd HH:mm:ss');
     }
     if (is_empty_date($special_to_date)) {
         $toDate->add(365, Zend_Date::DAY);
     }
     $toDate->setDate(substr($special_to_date, 0, 10), 'yyyy-MM-dd');
     $toDate->setTime(substr($special_to_date, 11, 8), 'HH:mm:ss');
     if (($fromDate->compare($cDate) == -1 || $fromDate->compare($cDate) == 0) && ($toDate->compare($cDate) == 1 || $toDate->compare($cDate) == 0)) {
         return true;
     }
     return false;
 }
开发者ID:brandontamm,项目名称:api-merchant-center,代码行数:46,代码来源:Abstract.php

示例15: _saveOrder

 protected function _saveOrder($data)
 {
     $fieldNoEnc = array('customers_id', 'orders_id', 'date_purchased', 'last_modified', 'orders_date_finished', 'orders_products_id', 'osc_magento_id', 'products_id');
     $importModel = $this->getImportModel();
     $timezone = $importModel->getTimezone();
     $customerIdPair = $this->getCustomerIdPair();
     $importId = $importModel->getId();
     $websiteId = $this->getWebsiteModel()->getId();
     if ($data['customers_id'] > 0 && isset($this->_customerIdPair[$data['customers_id']])) {
         foreach ($data as $field => $value) {
             if (!in_array($field, $fieldNoEnc)) {
                 $data[$field] = $this->convert($value);
             }
         }
         if ($data['date_purchased']) {
             $preparePurchased = explode(' ', $data['date_purchased']);
             $dateFormat = 'YYYY-MM-dd HH:mm:ss';
             $datePurchased = new Zend_Date();
             $datePurchased->setTimezone($timezone);
             $datePurchased->setDate($preparePurchased[0], 'YYYY-MM-dd');
             $datePurchased->setTime($preparePurchased[1], 'HH:mm:ss');
             $datePurchased->setTimezone('GMT');
             $data['date_purchased'] = $datePurchased->toString($dateFormat);
         }
         if ($data['last_modified']) {
             $prepareModified = explode(' ', $data['last_modified']);
             $dateModified = new Zend_Date();
             $dateModified->setTimezone($timezone);
             $dateModified->setDate($prepareModified[0], 'YYYY-MM-dd');
             $dateModified->setTime($prepareModified[1], 'HH:mm:ss');
             $dateModified->setTimezone('GMT');
             $data['last_modified'] = $dateModified->toString($dateFormat);
         }
         if ($data['orders_date_finished']) {
             $prepareFinished = explode(' ', $data['orders_date_finished']);
             $dateFinished = new Zend_Date();
             $dateFinished->setTimezone($timezone);
             $dateFinished->setDate($prepareFinished[0], 'YYYY-MM-dd');
             $dateFinished->setTime($prepareFinished[1], 'HH:mm:ss');
             $dateFinished->setTimezone('GMT');
             $data['orders_date_finished'] = $dateFinished->toString($dateFormat);
         }
         $data['magento_customers_id'] = $this->_customerIdPair[$data['customers_id']];
         // get Magento CustomerId
         $data['import_id'] = $importId;
         $data['website_id'] = $websiteId;
         $data['orders_status'] = $data['orders_status_name'];
         unset($data['orders_status_name']);
         $this->_getWriteAdapter()->insert($this->getTable('oscommerce_order'), $data);
         $oscMagentoId = $this->_getWriteAdapter()->lastInsertId();
         $this->_saveRows++;
         // Get orders products
         $select = "SELECT `orders_products_id`, `orders_id`, `products_id` ";
         $select .= ", `products_model`, `products_name`, `products_price`, `final_price` ";
         $select .= ", `products_tax`, `products_quantity` ";
         $select .= " FROM `{$this->getOscTable('orders_products')}` WHERE `orders_id`={$data['orders_id']}";
         if ($orderProducts = $this->_getForeignAdapter()->fetchAll($select)) {
             foreach ($orderProducts as $orderProduct) {
                 unset($orderProduct['orders_id']);
                 unset($orderProduct['orders_products_id']);
                 $orderProduct['osc_magento_id'] = $oscMagentoId;
                 foreach ($orderProduct as $field => $value) {
                     if (!in_array($field, $fieldNoEnc)) {
                         $orderProduct[$field] = $this->convert($value);
                     }
                 }
                 $this->_getWriteAdapter()->insert($this->getTable('oscommerce_order_products'), $orderProduct);
             }
         }
         // Get orders totals
         $select = "SELECT `orders_total_id`, `orders_id`, `title`, `text`, `value`, `class`, `sort_order` ";
         $select .= " FROM `{$this->getOscTable('orders_total')}` WHERE `orders_id`={$data['orders_id']} ORDER BY `sort_order`";
         if ($orderTotals = $this->_getForeignAdapter()->fetchAll($select)) {
             foreach ($orderTotals as $orderTotal) {
                 unset($orderTotal['orders_id']);
                 unset($orderTotal['orders_total_id']);
                 $orderTotal['osc_magento_id'] = $oscMagentoId;
                 $orderTotal['title'] = $this->convert($orderTotal['title']);
                 $orderTotal['text'] = $this->convert($orderTotal['text']);
                 $this->_getWriteAdapter()->insert($this->getTable('oscommerce_order_total'), $orderTotal);
             }
         }
         $defaultLanguage = $this->getOscDefaultLanguage();
         $defaultLanguageId = $defaultLanguage['id'];
         // Get orders status history
         $select = "SELECT `osh`.`orders_status_history_id`, `osh`.`orders_id`, `osh`.`orders_status_id` ";
         $select .= ", `os`.`orders_status_name` `orders_status`, `osh`.`date_added`, `osh`.`customer_notified`, `osh`.`comments` ";
         $select .= " FROM `{$this->getOscTable('orders_status_history')}` osh ";
         $select .= " LEFT JOIN `{$this->getOscTable('orders_status')}` os ON `os`.`orders_status_id`=`osh`.`orders_status_id` ";
         $select .= " AND `os`.`language_id`={$defaultLanguageId}";
         $select .= " WHERE `osh`.`orders_id`={$data['orders_id']}";
         if ($orderHistories = $this->_getForeignAdapter()->fetchAll($select)) {
             foreach ($orderHistories as $orderHistory) {
                 unset($orderHistory['orders_id']);
                 unset($orderHistory['orders_status_history_id']);
                 $orderHistory['osc_magento_id'] = $oscMagentoId;
                 $prepareAdded = explode(' ', $orderHistory['date_added']);
                 $dateFormat = 'YYYY-MM-dd HH:mm:ss';
                 $dateAdded = new Zend_Date();
                 $dateAdded->setTimezone($timezone);
//.........这里部分代码省略.........
开发者ID:rlucia,项目名称:magento-oscom-migration-tool,代码行数:101,代码来源:Oscommerce.php


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