コード例 #1
0
 /**
  * Convert given date to default (UTC) timezone
  *
  * @param int $date
  * @param LocaleInterface $locale
  * @return \Magento\Framework\Stdlib\DateTime\Date|null
  */
 protected function convertDate($date, LocaleInterface $locale)
 {
     try {
         $dateObj = $this->localeDate->date(null, null, $locale, false);
         //set default timezone for store (admin)
         $dateObj->setTimezone($this->scopeConfig->getValue($this->localeDate->getDefaultTimezonePath(), \Magento\Framework\Store\ScopeInterface::SCOPE_STORE));
         //set beginning of day
         $dateObj->setHour(00);
         $dateObj->setMinute(00);
         $dateObj->setSecond(00);
         //set date with applying timezone of store
         $dateObj->set($date, null, $locale);
         //convert store date to default date in UTC timezone without DST
         $dateObj->setTimezone(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::DEFAULT_TIMEZONE);
         return $dateObj;
     } catch (\Exception $e) {
         return null;
     }
 }
コード例 #2
0
ファイル: Full.php プロジェクト: shabbirvividads/magento2
 /**
  * Retrieve Date value for store
  *
  * @param int $storeId
  * @param string $date
  * @return string|null
  */
 protected function getStoreDate($storeId, $date = null)
 {
     if (!isset($this->dates[$storeId])) {
         $timezone = $this->scopeConfig->getValue($this->localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $this->localeResolver->emulate($storeId);
         $dateObj = new \DateTime();
         $dateObj->setTimezone(new \DateTimeZone($timezone));
         $this->dates[$storeId] = $dateObj;
         $this->localeResolver->revert();
     }
     if (!$this->dateTime->isEmptyDate($date)) {
         /** @var \DateTime $dateObj */
         $dateObj = $this->dates[$storeId];
         return $this->localeDate->formatDateTime($dateObj, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE);
     }
     return null;
 }
コード例 #3
0
ファイル: Full.php プロジェクト: aiesh/magento2
 /**
  * Retrieve Date value for store
  *
  * @param int $storeId
  * @param string $date
  * @return string|null
  */
 protected function getStoreDate($storeId, $date = null)
 {
     if (!isset($this->dates[$storeId])) {
         $timezone = $this->scopeConfig->getValue($this->localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $locale = $this->scopeConfig->getValue($this->localeResolver->getDefaultLocalePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $locale = new \Zend_Locale($locale);
         $dateObj = new \Magento\Framework\Stdlib\DateTime\Date(null, null, $locale);
         $dateObj->setTimezone($timezone);
         $this->dates[$storeId] = [$dateObj, $locale->getTranslation(null, 'date', $locale)];
     }
     if (!$this->dateTime->isEmptyDate($date)) {
         list($dateObj, $format) = $this->dates[$storeId];
         $dateObj->setDate($date, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT);
         return $dateObj->toString($format);
     }
     return null;
 }
コード例 #4
0
ファイル: Installer.php プロジェクト: aiesh/magento2
 /**
  * Database installation
  *
  * @return $this
  */
 public function installDb()
 {
     $this->_dbUpdater->updateScheme();
     $data = $this->getDataModel()->getConfigData();
     /**
      * Saving host information into DB
      */
     if (!empty($data['use_rewrites'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_USE_REWRITES, 1);
     }
     if (!empty($data['enable_charts'])) {
         $this->_installSetup->setConfigData(\Magento\Backend\Block\Dashboard::XML_PATH_ENABLE_CHARTS, 1);
     } else {
         $this->_installSetup->setConfigData(\Magento\Backend\Block\Dashboard::XML_PATH_ENABLE_CHARTS, 0);
     }
     if (!empty($data['admin_no_form_key'])) {
         $this->_installSetup->setConfigData('admin/security/use_form_key', 0);
     }
     $unsecureBaseUrl = $this->_storeManager->getStore()->getBaseUrl('web');
     if (!empty($data['unsecure_base_url'])) {
         $unsecureBaseUrl = $data['unsecure_base_url'];
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecureBaseUrl);
     }
     if (!empty($data['use_secure'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_FRONTEND, 1);
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $data['secure_base_url']);
         if (!empty($data['use_secure_admin'])) {
             $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, 1);
         }
     } elseif (!empty($data['unsecure_base_url'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $unsecureBaseUrl);
     }
     /**
      * Saving locale information into DB
      */
     $locale = $this->getDataModel()->getLocaleData();
     if (!empty($locale['locale'])) {
         $this->_installSetup->setConfigData($this->_localeResolver->getDefaultLocalePath(), $locale['locale']);
     }
     if (!empty($locale['timezone'])) {
         $this->_installSetup->setConfigData($this->_localeDate->getDefaultTimezonePath(), $locale['timezone']);
     }
     if (!empty($locale['currency'])) {
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, $locale['currency']);
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_DEFAULT, $locale['currency']);
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW, $locale['currency']);
     }
     if (!empty($data['order_increment_prefix'])) {
         $this->_setOrderIncrementPrefix($this->_installSetup, $data['order_increment_prefix']);
     }
     return $this;
 }