Skip to content

Commit

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

Magetwo 43960 custom timezone merged
  • Loading branch information
He, Joan(johe) committed Oct 30, 2015
2 parents 116d6ac + cefaa2f commit 3709c59
Show file tree
Hide file tree
Showing 80 changed files with 375 additions and 687 deletions.
5 changes: 2 additions & 3 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@
if (!empty($_SERVER['MAGE_PROFILER'])) {
\Magento\Framework\Profiler::applyConfig($_SERVER['MAGE_PROFILER'], BP, !empty($_REQUEST['isAjax']));
}
if (ini_get('date.timezone') == '') {
date_default_timezone_set('UTC');
}

date_default_timezone_set('UTC');
13 changes: 0 additions & 13 deletions app/code/Magento/Authorization/Model/ResourceModel/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,16 @@ class Role extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
*/
protected $_cache;

/**
* @var \Magento\Framework\Stdlib\DateTime
*/
protected $dateTime;

/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Framework\App\CacheInterface $cache
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param string $connectionName
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Framework\App\CacheInterface $cache,
\Magento\Framework\Stdlib\DateTime $dateTime,
$connectionName = null
) {
$this->dateTime = $dateTime;
parent::__construct($context, $connectionName);
$this->_cache = $cache->getFrontend();
}
Expand All @@ -67,11 +59,6 @@ protected function _construct()
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
{
if (!$role->getId()) {
$role->setCreated($this->dateTime->formatDate(true));
}
$role->setModified($this->dateTime->formatDate(true));

if ($role->getId() == '') {
if ($role->getIdFieldName()) {
$role->unsetData($role->getIdFieldName());
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Backend/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<preference for="Magento\Backend\App\ConfigInterface" type="Magento\Backend\App\Config" />
<preference for="Magento\Framework\App\Response\Http\FileFactory" type="Magento\Backend\App\Response\Http\FileFactory" />
<preference for="Magento\Framework\View\Layout\GeneratorPool" type="Magento\Backend\Model\View\Layout\GeneratorPool" />
<type name="Magento\Framework\Stdlib\DateTime\Timezone">
<arguments>
<argument name="scopeType" xsi:type="const">Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Result\Page">
<arguments>
<argument name="layoutReaderPool" xsi:type="object">pageConfigRenderPool</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Stock extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb impleme
protected $_scopeConfig;

/**
* @var \Magento\Framework\Stdlib\DateTime
* @var \Magento\Framework\Stdlib\DateTime\DateTime
*/
protected $dateTime;

Expand All @@ -81,15 +81,15 @@ class Stock extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb impleme
/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
* @param StockConfigurationInterface $stockConfiguration
* @param StoreManagerInterface $storeManager
* @param string $connectionName
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
StockConfigurationInterface $stockConfiguration,
StoreManagerInterface $storeManager,
$connectionName = null
Expand Down Expand Up @@ -267,7 +267,7 @@ public function updateLowStockDate($website)
'(use_config_notify_stock_qty = 1 AND qty < ?)',
$this->_configNotifyStockQty
) . ' OR (use_config_notify_stock_qty = 0 AND qty < notify_stock_qty)';
$currentDbTime = $connection->quoteInto('?', $this->dateTime->formatDate(true));
$currentDbTime = $connection->quoteInto('?', $this->dateTime->gmtDate());
$conditionalDate = $connection->getCheckSql($condition, $currentDbTime, 'NULL');

$value = ['low_stock_date' => new \Zend_Db_Expr($conditionalDate)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
</item>
</argument>
</column>
<column name="creation_time">
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -277,7 +277,7 @@
</item>
</argument>
</column>
<column name="update_time">
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
</item>
</argument>
</column>
<column name="creation_time">
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -303,7 +303,7 @@
</item>
</argument>
</column>
<column name="update_time">
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -313,7 +313,7 @@
</item>
</argument>
</column>
<column name="custom_theme_from">
<column name="custom_theme_from" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand All @@ -326,7 +326,7 @@
</item>
</argument>
</column>
<column name="custom_theme_to">
<column name="custom_theme_to" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ public function getStoreCreateDate()
{
$createdAt = $this->getCustomer()->getCreatedAt();
try {
$date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $createdAt, true);
return $this->formatDate($date, \IntlDateFormatter::MEDIUM, true);
return $this->formatDate(
$createdAt,
\IntlDateFormatter::MEDIUM,
true,
$this->getStoreCreateDateTimezone()
);
} catch (\Exception $e) {
$this->_logger->critical($e);
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,12 @@
</item>
</argument>
</column>
<column name="created_at">
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="dataType" xsi:type="string">date</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="label" xsi:type="string" translate="true">Customer Since</item>
<item name="sortOrder" xsi:type="number">100</item>
</item>
Expand All @@ -332,7 +333,7 @@
</item>
</argument>
</column>
<column name="last_visit_at">
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
Expand Down Expand Up @@ -380,7 +381,7 @@
</item>
</argument>
</column>
<column name="dob">
<column name="dob" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,22 @@
</item>
</argument>
</column> -->
<column name="first_visit_at">
<column name="first_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="dataType" xsi:type="string">date</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="label" xsi:type="string" translate="true">Session Start Time</item>
</item>
</argument>
</column>
<column name="last_visit_at">
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="dataType" xsi:type="string">date</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="label" xsi:type="string" translate="true">Last Activity</item>
</item>
</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
class Created extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
{
/**
* @var \Magento\Framework\Stdlib\DateTime
* @var \Magento\Framework\Stdlib\DateTime\DateTime
*/
protected $dateTime;

/**
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
* @codeCoverageIgnore
*/
public function __construct(\Magento\Framework\Stdlib\DateTime $dateTime)
public function __construct(\Magento\Framework\Stdlib\DateTime\DateTime $dateTime)
{
$this->dateTime = $dateTime;
}
Expand All @@ -34,10 +34,8 @@ public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
if ($object->isObjectNew() && $object->getData($attributeCode) === null) {
$object->setData(
$attributeCode,
(new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)
);
//$object->setData($attributeCode, $this->dateTime->gmtDate());
$object->setData($attributeCode, gmdate('Y-m-d H:i:s'));
}

return $this;
Expand Down
5 changes: 0 additions & 5 deletions app/code/Magento/Email/Model/ResourceModel/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,7 @@ public function checkCodeUsage(\Magento\Email\Model\Template $template)
*/
protected function _beforeSave(AbstractModel $object)
{
if ($object->isObjectNew()) {
$object->setAddedAt($this->dateTime->formatDate(true));
}
$object->setModifiedAt($this->dateTime->formatDate(true));
$object->setTemplateType((int)$object->getTemplateType());

return parent::_beforeSave($object);
}

Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Email/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'added_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
[],
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
'Date of Template Creation'
)->addColumn(
'modified_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
[],
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
'Date of Template Modification'
)->addColumn(
'orig_template_code',
Expand Down
23 changes: 0 additions & 23 deletions app/code/Magento/Integration/Model/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,20 @@ class Integration extends \Magento\Framework\Model\AbstractModel

/**#@-*/

/**
* @var \Magento\Framework\Stdlib\DateTime
*/
protected $_dateTime;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
$this->_dateTime = $dateTime;
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}

Expand All @@ -104,21 +96,6 @@ protected function _construct()
$this->_init('Magento\Integration\Model\ResourceModel\Integration');
}

/**
* Prepare data to be saved to database
*
* @return $this
*/
public function beforeSave()
{
parent::beforeSave();
if ($this->isObjectNew()) {
$this->setCreatedAt($this->_dateTime->formatDate(true));
}
$this->setUpdatedAt($this->_dateTime->formatDate(true));
return $this;
}

/**
* Load integration by oAuth consumer ID.
*
Expand Down
22 changes: 0 additions & 22 deletions app/code/Magento/Integration/Model/Oauth/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,13 @@ class Token extends \Magento\Framework\Model\AbstractModel
*/
protected $_keyLengthFactory;

/**
* @var \Magento\Framework\Stdlib\DateTime
*/
protected $_dateTime;

/**
* Initialize dependencies.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory $keyLengthFactory
* @param \Magento\Framework\Url\Validator $urlValidator
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Integration\Model\Oauth\ConsumerFactory $consumerFactory
* @param \Magento\Integration\Helper\Oauth\Data $oauthData
* @param OauthHelper $oauthHelper
Expand All @@ -106,7 +100,6 @@ public function __construct(
\Magento\Framework\Registry $registry,
\Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory $keyLengthFactory,
\Magento\Framework\Url\Validator $urlValidator,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Integration\Model\Oauth\ConsumerFactory $consumerFactory,
\Magento\Integration\Helper\Oauth\Data $oauthData,
OauthHelper $oauthHelper,
Expand All @@ -117,7 +110,6 @@ public function __construct(
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
$this->_keyLengthFactory = $keyLengthFactory;
$this->_urlValidator = $urlValidator;
$this->_dateTime = $dateTime;
$this->_consumerFactory = $consumerFactory;
$this->_oauthData = $oauthData;
$this->_oauthHelper = $oauthHelper;
Expand Down Expand Up @@ -251,20 +243,6 @@ public function __toString()
return http_build_query(['oauth_token' => $this->getToken(), 'oauth_token_secret' => $this->getSecret()]);
}

/**
* Before save actions
*
* @return $this
*/
public function beforeSave()
{
if ($this->isObjectNew() && null === $this->getCreatedAt()) {
$this->setCreatedAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
}
parent::beforeSave();
return $this;
}

/**
* Validate data
*
Expand Down
Loading

0 comments on commit 3709c59

Please sign in to comment.