示例#1
0
文件: Date.php 项目: aiesh/magento2
 /**
  * Return formatted option value for quote option
  *
  * @param string $optionValue Prepared for cart option value
  * @return string
  */
 public function getFormattedOptionValue($optionValue)
 {
     if ($this->_formattedOptionValue === null) {
         $option = $this->getOption();
         if ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE) {
             $format = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM);
             $result = $this->_localeDate->date($optionValue, \Zend_Date::ISO_8601, null, false)->toString($format);
         } elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME) {
             $format = $this->_localeDate->getDateTimeFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
             $result = $this->_localeDate->date($optionValue, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT, null, false)->toString($format);
         } elseif ($this->getOption()->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME) {
             $date = new \Magento\Framework\Stdlib\DateTime\Date($optionValue);
             $result = date($this->is24hTimeFormat() ? 'H:i' : 'h:i a', $date->getTimestamp());
         } else {
             $result = $optionValue;
         }
         $this->_formattedOptionValue = $result;
     }
     return $this->_formattedOptionValue;
 }
示例#2
0
 /**
  * Convert the start datetime (if set) to proper locale/timezone and return
  *
  * @return string
  */
 public function exportStartDatetime()
 {
     $datetime = $this->getStartDatetime();
     if (!$datetime || !$this->_localeDate || !$this->_store) {
         return '';
     }
     $date = $this->_localeDate->scopeDate($this->_store, strtotime($datetime), true);
     return $date->toString($this->_localeDate->getDateTimeFormat(TimezoneInterface::FORMAT_TYPE_SHORT));
 }
示例#3
0
文件: Queue.php 项目: aiesh/magento2
 /**
  * Set $_data['queue_start'] based on string from backend, which based on locale.
  *
  * @param string|null $startAt start date of the mailing queue
  * @return $this
  */
 public function setQueueStartAtByString($startAt)
 {
     if (is_null($startAt) || $startAt == '') {
         $this->setQueueStartAt(null);
     } else {
         $format = $this->_localeDate->getDateTimeFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM);
         $time = $this->_localeDate->date($startAt, $format)->getTimestamp();
         $this->setQueueStartAt($this->_date->gmtDate(null, $time));
     }
     return $this;
 }