Skip to content

Commit 5c64428

Browse files
authored
Merge pull request #4711 from magento-chaika/Chaika-PR-2019-08-29
[chaika] MC-17824: MAP and MSRP are being used interchangeably when they are different
2 parents 31a6cd7 + aa3ea45 commit 5c64428

File tree

6 files changed

+325
-183
lines changed

6 files changed

+325
-183
lines changed

app/code/Magento/Customer/Block/Widget/Dob.php

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,34 @@ public function isRequired()
9999
*/
100100
public function setDate($date)
101101
{
102-
$this->setTime($date ? strtotime($date) : false);
102+
$this->setTime($this->filterTime($date));
103103
$this->setValue($this->applyOutputFilter($date));
104104
return $this;
105105
}
106106

107+
/**
108+
* Sanitizes time
109+
*
110+
* @param mixed $value
111+
* @return bool|int
112+
*/
113+
private function filterTime($value)
114+
{
115+
$time = false;
116+
if ($value) {
117+
if ($value instanceof \DateTimeInterface) {
118+
$time = $value->getTimestamp();
119+
} elseif (is_numeric($value)) {
120+
$time = $value;
121+
} elseif (is_string($value)) {
122+
$time = strtotime($value);
123+
$time = $time === false ? $this->_localeDate->date($value, null, false, false)->getTimestamp() : $time;
124+
}
125+
}
126+
127+
return $time;
128+
}
129+
107130
/**
108131
* Return Data Form Filter or false
109132
*
@@ -200,21 +223,23 @@ public function getStoreLabel($attributeCode)
200223
*/
201224
public function getFieldHtml()
202225
{
203-
$this->dateElement->setData([
204-
'extra_params' => $this->getHtmlExtraParams(),
205-
'name' => $this->getHtmlId(),
206-
'id' => $this->getHtmlId(),
207-
'class' => $this->getHtmlClass(),
208-
'value' => $this->getValue(),
209-
'date_format' => $this->getDateFormat(),
210-
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
211-
'years_range' => '-120y:c+nn',
212-
'max_date' => '-1d',
213-
'change_month' => 'true',
214-
'change_year' => 'true',
215-
'show_on' => 'both',
216-
'first_day' => $this->getFirstDay()
217-
]);
226+
$this->dateElement->setData(
227+
[
228+
'extra_params' => $this->getHtmlExtraParams(),
229+
'name' => $this->getHtmlId(),
230+
'id' => $this->getHtmlId(),
231+
'class' => $this->getHtmlClass(),
232+
'value' => $this->getValue(),
233+
'date_format' => $this->getDateFormat(),
234+
'image' => $this->getViewFileUrl('Magento_Theme::calendar.png'),
235+
'years_range' => '-120y:c+nn',
236+
'max_date' => '-1d',
237+
'change_month' => 'true',
238+
'change_year' => 'true',
239+
'show_on' => 'both',
240+
'first_day' => $this->getFirstDay()
241+
]
242+
);
218243
return $this->dateElement->getHtml();
219244
}
220245

0 commit comments

Comments
 (0)