Skip to content

Commit 3709c59

Browse files
author
He, Joan(johe)
committed
Merge pull request #75 from magento-extensibility/MAGETWO-43960-custom-timezone-merged
Magetwo 43960 custom timezone merged
2 parents 116d6ac + cefaa2f commit 3709c59

File tree

80 files changed

+375
-687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+375
-687
lines changed

app/bootstrap.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@
3434
if (!empty($_SERVER['MAGE_PROFILER'])) {
3535
\Magento\Framework\Profiler::applyConfig($_SERVER['MAGE_PROFILER'], BP, !empty($_REQUEST['isAjax']));
3636
}
37-
if (ini_get('date.timezone') == '') {
38-
date_default_timezone_set('UTC');
39-
}
37+
38+
date_default_timezone_set('UTC');

app/code/Magento/Authorization/Model/ResourceModel/Role.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,16 @@ class Role extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
2626
*/
2727
protected $_cache;
2828

29-
/**
30-
* @var \Magento\Framework\Stdlib\DateTime
31-
*/
32-
protected $dateTime;
33-
3429
/**
3530
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
3631
* @param \Magento\Framework\App\CacheInterface $cache
37-
* @param \Magento\Framework\Stdlib\DateTime $dateTime
3832
* @param string $connectionName
3933
*/
4034
public function __construct(
4135
\Magento\Framework\Model\ResourceModel\Db\Context $context,
4236
\Magento\Framework\App\CacheInterface $cache,
43-
\Magento\Framework\Stdlib\DateTime $dateTime,
4437
$connectionName = null
4538
) {
46-
$this->dateTime = $dateTime;
4739
parent::__construct($context, $connectionName);
4840
$this->_cache = $cache->getFrontend();
4941
}
@@ -67,11 +59,6 @@ protected function _construct()
6759
*/
6860
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
6961
{
70-
if (!$role->getId()) {
71-
$role->setCreated($this->dateTime->formatDate(true));
72-
}
73-
$role->setModified($this->dateTime->formatDate(true));
74-
7562
if ($role->getId() == '') {
7663
if ($role->getIdFieldName()) {
7764
$role->unsetData($role->getIdFieldName());

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
<preference for="Magento\Backend\App\ConfigInterface" type="Magento\Backend\App\Config" />
1616
<preference for="Magento\Framework\App\Response\Http\FileFactory" type="Magento\Backend\App\Response\Http\FileFactory" />
1717
<preference for="Magento\Framework\View\Layout\GeneratorPool" type="Magento\Backend\Model\View\Layout\GeneratorPool" />
18+
<type name="Magento\Framework\Stdlib\DateTime\Timezone">
19+
<arguments>
20+
<argument name="scopeType" xsi:type="const">Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT</argument>
21+
</arguments>
22+
</type>
1823
<type name="Magento\Framework\View\Result\Page">
1924
<arguments>
2025
<argument name="layoutReaderPool" xsi:type="object">pageConfigRenderPool</argument>

app/code/Magento/CatalogInventory/Model/ResourceModel/Stock.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Stock extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb impleme
6969
protected $_scopeConfig;
7070

7171
/**
72-
* @var \Magento\Framework\Stdlib\DateTime
72+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
7373
*/
7474
protected $dateTime;
7575

@@ -81,15 +81,15 @@ class Stock extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb impleme
8181
/**
8282
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
8383
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
84-
* @param \Magento\Framework\Stdlib\DateTime $dateTime
84+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
8585
* @param StockConfigurationInterface $stockConfiguration
8686
* @param StoreManagerInterface $storeManager
8787
* @param string $connectionName
8888
*/
8989
public function __construct(
9090
\Magento\Framework\Model\ResourceModel\Db\Context $context,
9191
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
92-
\Magento\Framework\Stdlib\DateTime $dateTime,
92+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
9393
StockConfigurationInterface $stockConfiguration,
9494
StoreManagerInterface $storeManager,
9595
$connectionName = null
@@ -267,7 +267,7 @@ public function updateLowStockDate($website)
267267
'(use_config_notify_stock_qty = 1 AND qty < ?)',
268268
$this->_configNotifyStockQty
269269
) . ' OR (use_config_notify_stock_qty = 0 AND qty < notify_stock_qty)';
270-
$currentDbTime = $connection->quoteInto('?', $this->dateTime->formatDate(true));
270+
$currentDbTime = $connection->quoteInto('?', $this->dateTime->gmtDate());
271271
$conditionalDate = $connection->getCheckSql($condition, $currentDbTime, 'NULL');
272272

273273
$value = ['low_stock_date' => new \Zend_Db_Expr($conditionalDate)];

app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
</item>
268268
</argument>
269269
</column>
270-
<column name="creation_time">
270+
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
271271
<argument name="data" xsi:type="array">
272272
<item name="config" xsi:type="array">
273273
<item name="filter" xsi:type="string">dateRange</item>
@@ -277,7 +277,7 @@
277277
</item>
278278
</argument>
279279
</column>
280-
<column name="update_time">
280+
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
281281
<argument name="data" xsi:type="array">
282282
<item name="config" xsi:type="array">
283283
<item name="filter" xsi:type="string">dateRange</item>

app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
</item>
294294
</argument>
295295
</column>
296-
<column name="creation_time">
296+
<column name="creation_time" class="Magento\Ui\Component\Listing\Columns\Date">
297297
<argument name="data" xsi:type="array">
298298
<item name="config" xsi:type="array">
299299
<item name="filter" xsi:type="string">dateRange</item>
@@ -303,7 +303,7 @@
303303
</item>
304304
</argument>
305305
</column>
306-
<column name="update_time">
306+
<column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date">
307307
<argument name="data" xsi:type="array">
308308
<item name="config" xsi:type="array">
309309
<item name="filter" xsi:type="string">dateRange</item>
@@ -313,7 +313,7 @@
313313
</item>
314314
</argument>
315315
</column>
316-
<column name="custom_theme_from">
316+
<column name="custom_theme_from" class="Magento\Ui\Component\Listing\Columns\Date">
317317
<argument name="data" xsi:type="array">
318318
<item name="config" xsi:type="array">
319319
<item name="filter" xsi:type="string">dateRange</item>
@@ -326,7 +326,7 @@
326326
</item>
327327
</argument>
328328
</column>
329-
<column name="custom_theme_to">
329+
<column name="custom_theme_to" class="Magento\Ui\Component\Listing\Columns\Date">
330330
<argument name="data" xsi:type="array">
331331
<item name="config" xsi:type="array">
332332
<item name="filter" xsi:type="string">dateRange</item>

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ public function getStoreCreateDate()
195195
{
196196
$createdAt = $this->getCustomer()->getCreatedAt();
197197
try {
198-
$date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $createdAt, true);
199-
return $this->formatDate($date, \IntlDateFormatter::MEDIUM, true);
198+
return $this->formatDate(
199+
$createdAt,
200+
\IntlDateFormatter::MEDIUM,
201+
true,
202+
$this->getStoreCreateDateTimezone()
203+
);
200204
} catch (\Exception $e) {
201205
$this->_logger->critical($e);
202206
return '';

app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,12 @@
310310
</item>
311311
</argument>
312312
</column>
313-
<column name="created_at">
313+
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
314314
<argument name="data" xsi:type="array">
315315
<item name="config" xsi:type="array">
316316
<item name="filter" xsi:type="string">dateRange</item>
317317
<item name="dataType" xsi:type="string">date</item>
318+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
318319
<item name="label" xsi:type="string" translate="true">Customer Since</item>
319320
<item name="sortOrder" xsi:type="number">100</item>
320321
</item>
@@ -332,7 +333,7 @@
332333
</item>
333334
</argument>
334335
</column>
335-
<column name="last_visit_at">
336+
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
336337
<argument name="data" xsi:type="array">
337338
<item name="config" xsi:type="array">
338339
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
@@ -380,7 +381,7 @@
380381
</item>
381382
</argument>
382383
</column>
383-
<column name="dob">
384+
<column name="dob" class="Magento\Ui\Component\Listing\Columns\Date">
384385
<argument name="data" xsi:type="array">
385386
<item name="config" xsi:type="array">
386387
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>

app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,22 @@
142142
</item>
143143
</argument>
144144
</column> -->
145-
<column name="first_visit_at">
145+
<column name="first_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
146146
<argument name="data" xsi:type="array">
147147
<item name="config" xsi:type="array">
148+
<item name="filter" xsi:type="string">dateRange</item>
148149
<item name="dataType" xsi:type="string">date</item>
150+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
149151
<item name="label" xsi:type="string" translate="true">Session Start Time</item>
150152
</item>
151153
</argument>
152154
</column>
153-
<column name="last_visit_at">
155+
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
154156
<argument name="data" xsi:type="array">
155157
<item name="config" xsi:type="array">
156158
<item name="filter" xsi:type="string">dateRange</item>
157159
<item name="dataType" xsi:type="string">date</item>
160+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
158161
<item name="label" xsi:type="string" translate="true">Last Activity</item>
159162
</item>
160163
</argument>

app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
class Created extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
1212
{
1313
/**
14-
* @var \Magento\Framework\Stdlib\DateTime
14+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
1515
*/
1616
protected $dateTime;
1717

1818
/**
19-
* @param \Magento\Framework\Stdlib\DateTime $dateTime
19+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
2020
* @codeCoverageIgnore
2121
*/
22-
public function __construct(\Magento\Framework\Stdlib\DateTime $dateTime)
22+
public function __construct(\Magento\Framework\Stdlib\DateTime\DateTime $dateTime)
2323
{
2424
$this->dateTime = $dateTime;
2525
}
@@ -34,10 +34,8 @@ public function beforeSave($object)
3434
{
3535
$attributeCode = $this->getAttribute()->getAttributeCode();
3636
if ($object->isObjectNew() && $object->getData($attributeCode) === null) {
37-
$object->setData(
38-
$attributeCode,
39-
(new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)
40-
);
37+
//$object->setData($attributeCode, $this->dateTime->gmtDate());
38+
$object->setData($attributeCode, gmdate('Y-m-d H:i:s'));
4139
}
4240

4341
return $this;

0 commit comments

Comments
 (0)