diff --git a/app/code/Magento/Email/Model/ResourceModel/Template.php b/app/code/Magento/Email/Model/ResourceModel/Template.php index 7686b2ddde55a..5ac2a2bea68dd 100644 --- a/app/code/Magento/Email/Model/ResourceModel/Template.php +++ b/app/code/Magento/Email/Model/ResourceModel/Template.php @@ -14,22 +14,14 @@ */ class Template extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { - /** - * @var \Magento\Framework\Stdlib\DateTime - */ - protected $dateTime; - /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context - * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param string $connectionName */ public function __construct( \Magento\Framework\Model\ResourceModel\Db\Context $context, - \Magento\Framework\Stdlib\DateTime $dateTime, $connectionName = null ) { - $this->dateTime = $dateTime; parent::__construct($context, $connectionName); } diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php index 3a088ef68fb76..c666119156776 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php @@ -11,7 +11,7 @@ */ namespace Magento\Reports\Controller\Adminhtml\Report; -use Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; abstract class AbstractReport extends \Magento\Backend\App\Action { @@ -26,26 +26,26 @@ abstract class AbstractReport extends \Magento\Backend\App\Action protected $_dateFilter; /** - * @var DateTimeFormatterInterface + * @var TimezoneInterface */ - protected $dateTimeFormatter; + protected $timezone; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory * @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter - * @param DateTimeFormatterInterface $dateTimeFormatter + * @param TimezoneInterface $timezone */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter, - DateTimeFormatterInterface $dateTimeFormatter + TimezoneInterface $timezone ) { parent::__construct($context); $this->_fileFactory = $fileFactory; $this->_dateFilter = $dateFilter; - $this->dateTimeFormatter = $dateTimeFormatter; + $this->timezone = $timezone; } /** @@ -134,14 +134,10 @@ protected function _showLastExecutionTime($flagCode, $refreshCode) $flag = $this->_objectManager->create('Magento\Reports\Model\Flag')->setReportFlagCode($flagCode)->loadSelf(); $updatedAt = 'undefined'; if ($flag->hasData()) { - $updatedAt = $this->dateTimeFormatter->formatObject( - $this->_objectManager->get( - 'Magento\Framework\Stdlib\DateTime\TimezoneInterface' - )->scopeDate( - 0, - $flag->getLastUpdate(), - true - ) + $updatedAt = $this->timezone->formatDate( + $flag->getLastUpdate(), + \IntlDateFormatter::MEDIUM, + true ); } diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php index 20976259737d8..ba1bc695a6f32 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php @@ -235,7 +235,7 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null) } /** - * @param \DateTimeInterface $date + * @param string|\DateTimeInterface $date * @param int $dateType * @param int $timeType * @param null $locale @@ -244,13 +244,17 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null) * @return string */ public function formatDateTime( - \DateTimeInterface $date, + $date, $dateType = \IntlDateFormatter::SHORT, $timeType = \IntlDateFormatter::SHORT, $locale = null, $timezone = null, $pattern = null ) { + if (!($date instanceof \DateTime)) { + $date = new \DateTime($date); + } + if ($timezone === null) { if ($date->getTimezone() == null || $date->getTimezone()->getName() == 'UTC' || $date->getTimezone()->getName() == '+00:00' diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php b/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php index 7bd873c0cf1e6..50494fb14fcb5 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php @@ -121,7 +121,7 @@ public function getConfigTimezone($scopeType = null, $scopeCode = null); public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null); /** - * @param \DateTimeInterface $date + * @param string|\DateTimeInterface $date * @param int $dateType * @param int $timeType * @param null $locale @@ -130,7 +130,7 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null); * @return string */ public function formatDateTime( - \DateTimeInterface $date, + $date, $dateType = \IntlDateFormatter::SHORT, $timeType = \IntlDateFormatter::SHORT, $locale = null,