Skip to content

Commit

Permalink
Merge pull request #161 from magento-extensibility/MAGETWO-43960-cust…
Browse files Browse the repository at this point in the history
…om-timezone-merged

[Extensibility] [Timezone] Magetwo 43960 custom timezone merged
  • Loading branch information
He, Joan(johe) committed Nov 12, 2015
2 parents a65e016 + 9aeba1b commit 71f2261
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
8 changes: 0 additions & 8 deletions app/code/Magento/Email/Model/ResourceModel/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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
);
}

Expand Down
8 changes: 6 additions & 2 deletions lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 71f2261

Please sign in to comment.