Skip to content

Commit a2bec20

Browse files
committed
MAGETWO-57835: [Github] Cannot save customer dob attribute if admin interface locale is en_GB #6323
- add ability for filtering by time
1 parent 4b8bd22 commit a2bec20

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

app/code/Magento/Ui/Component/Filters/Type/Date.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,26 @@ protected function applyFilter()
7979
}
8080

8181
if (is_array($value)) {
82+
$dateFrom = null;
83+
$dateTo = null;
84+
8285
if (isset($value['from'])) {
83-
$this->applyFilterByType(
84-
'gteq',
85-
$this->wrappedComponent->convertDate($value['from'], 0, 0, 0, $this->getData('config/skipTime'))
86-
);
86+
$dateFrom = $this->wrappedComponent->convertDate($value['from']);
87+
if ($this->getData('config/skipTime')) {
88+
$dateFrom->setTime(0, 0, 0);
89+
}
90+
$this->applyFilterByType('gteq', $dateFrom);
8791
}
8892

8993
if (isset($value['to'])) {
90-
$this->applyFilterByType('lteq', $this->wrappedComponent->convertDate($value['to'], 23, 59, 59));
94+
$dateTo = $this->wrappedComponent->convertDate($value['to']);
95+
if ($this->getData('config/skipTime')) {
96+
$dateTo->setTime(0, 0, 0);
97+
}
98+
if ($dateFrom == $dateTo) {
99+
$dateTo->setTime(23, 59, 59);
100+
}
101+
$this->applyFilterByType('lteq', $dateTo);
91102
}
92103
} else {
93104
$this->applyFilterByType('eq', $this->wrappedComponent->convertDate($value));

app/code/Magento/Ui/Component/Form/Element/DataType/Date.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,9 @@ public function getComponentName()
9797
* Convert given date to default (UTC) timezone
9898
*
9999
* @param int $date
100-
* @param int $hour
101-
* @param int $minute
102-
* @param int $second
103-
* @param bool $skipTime
104100
* @return \DateTime|null
105101
*/
106-
public function convertDate($date, $hour = 0, $minute = 0, $second = 0, $skipTime = false)
102+
public function convertDate($date)
107103
{
108104
try {
109105
$dateObj = $this->localeDate->date(
@@ -114,12 +110,8 @@ public function convertDate($date, $hour = 0, $minute = 0, $second = 0, $skipTim
114110
$this->getLocale(),
115111
true
116112
);
117-
$dateObj->setTime($hour, $minute, $second);
118113
//convert store date to default date in UTC timezone without DST
119114
$dateObj->setTimezone(new \DateTimeZone('UTC'));
120-
if ($skipTime) {
121-
$dateObj->setTime(0, 0, 0);
122-
}
123115
return $dateObj;
124116
} catch (\Exception $e) {
125117
return null;

0 commit comments

Comments
 (0)