Skip to content

Commit 2b53bf2

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.1-develop
Accepted Public Pull Requests: - #16585: [Backport] Remove the timezone from the date when retrieving the current month from a UTC timestamp. (by @mageprince) - #16632: [Backport] Small refactoring to better code readability (by @ronak2ram) Fixed GitHub Issues: - #15940: Wrong end of month at Reports for Europe/Berlin time zone if month contains 31 day (reported by @Stepa4man) has been fixed in #16585 by @mageprince in 2.1-develop branch Related commits: 1. efbe4de
2 parents e72b563 + 45bc0c9 commit 2b53bf2

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,18 @@ protected function _toHtml()
120120
if (!$this->_depends) {
121121
return '';
122122
}
123-
return '<script>
124-
require(["mage/adminhtml/form"], function(){
125-
new FormElementDependenceController(' .
126-
$this->_getDependsJson() .
127-
($this->_configOptions ? ', ' .
128-
$this->_jsonEncoder->encode(
129-
$this->_configOptions
130-
) : '') . '); });</script>';
123+
124+
$params = $this->_getDependsJson();
125+
126+
if ($this->_configOptions) {
127+
$params .= ', ' . $this->_jsonEncoder->encode($this->_configOptions);
128+
}
129+
130+
return "<script>
131+
require(['mage/adminhtml/form'], function(){
132+
new FormElementDependenceController({$params});
133+
});
134+
</script>";
131135
}
132136

133137
/**

app/code/Magento/Reports/Model/ResourceModel/Report/Collection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,11 @@ protected function _getMonthInterval(\DateTime $dateStart, \DateTime $dateEnd, $
211211
)
212212
);
213213
} else {
214+
// Transform the start date to UTC whilst preserving the date. This is required as getTimestamp()
215+
// is in UTC which may result in a different month from the original start date due to time zones.
216+
$dateStartUtc = (new \DateTime())->createFromFormat('d-m-Y g:i:s', $dateStart->format('d-m-Y 00:00:00'));
214217
$interval['end'] = $this->_localeDate->convertConfigTimeToUtc(
215-
$dateStart->format('Y-m-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59')
218+
$dateStart->format('Y-m-' . date('t', $dateStartUtc->getTimestamp()) . ' 23:59:59')
216219
);
217220
}
218221

dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ DoubleColon
8080
BarFactory
8181
PartialNamespace\BarFactory
8282
Product\OptionFactory
83+
FormElementDependenceController

0 commit comments

Comments
 (0)