Skip to content

Commit 294e46b

Browse files
committed
AC-12025::DOB issue: leading zero is missing for single digit month
1 parent f387ecb commit 294e46b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ public function getHtmlExtraParams()
303303
public function getDateFormat()
304304
{
305305
$dateFormat = $this->setTwoDayPlaces($this->_localeDate->getDateFormatWithLongYear());
306+
$dateFormat = $this->setTwoMonthPlaces($dateFormat);
306307
/** Escape RTL characters which are present in some locales and corrupt formatting */
307308
$escapedDateFormat = preg_replace('/[^MmDdYy\/\.\-]/', '', $dateFormat);
308309

@@ -440,4 +441,19 @@ private function setTwoDayPlaces(string $format): string
440441
$format
441442
);
442443
}
444+
445+
/**
446+
* Set 2 places for month value in format string
447+
*
448+
* @param string $format
449+
* @return string
450+
*/
451+
private function setTwoMonthPlaces(string $format): string
452+
{
453+
return preg_replace(
454+
'/(?<!M)M(?!M)/',
455+
'MM',
456+
$format
457+
);
458+
}
443459
}

app/code/Magento/Customer/view/frontend/web/js/validation.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ define([
1111
$.validator.addMethod(
1212
'validate-date',
1313
function (value, element, params) {
14-
if (params.dateFormat === 'M/dd/y') {
15-
params.dateFormat = 'MM/dd/y';
16-
}
1714
var dateFormat = utils.normalizeDate(params.dateFormat);
15+
1816
if (value === '') {
1917
return true;
2018
}

0 commit comments

Comments
 (0)