Skip to content

Commit e238a68

Browse files
committed
Merge remote-tracking branch 'origin/MC-36718' into 2.4-develop-pr42
2 parents fa211bd + c36177c commit e238a68

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function getHtmlExtraParams()
281281
*/
282282
public function getDateFormat()
283283
{
284-
$dateFormat = $this->_localeDate->getDateFormatWithLongYear();
284+
$dateFormat = $this->setTwoDayPlaces($this->_localeDate->getDateFormatWithLongYear());
285285
/** Escape RTL characters which are present in some locales and corrupt formatting */
286286
$escapedDateFormat = preg_replace('/[^MmDdYy\/\.\-]/', '', $dateFormat);
287287

@@ -377,4 +377,19 @@ public function getFirstDay()
377377
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
378378
);
379379
}
380+
381+
/**
382+
* Set 2 places for day value in format string
383+
*
384+
* @param string $format
385+
* @return string
386+
*/
387+
private function setTwoDayPlaces(string $format): string
388+
{
389+
return preg_replace(
390+
'/(?<!d)d(?!d)/',
391+
'dd',
392+
$format
393+
);
394+
}
380395
}

app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DobTest extends TestCase
5151
const YEAR = '2014';
5252

5353
// Value of date('Y', strtotime(self::DATE))
54-
const DATE_FORMAT = 'M/d/y';
54+
const DATE_FORMAT = 'M/dd/y';
5555

5656
/** Constants used by Dob::setDateInput($code, $html) */
5757
const DAY_HTML =
@@ -356,11 +356,15 @@ public function getDateFormatDataProvider(): array
356356
[
357357
'ar_SA',
358358
preg_replace(
359-
'/[^MmDdYy\/\.\-]/',
360-
'',
361-
(new DateFormatterFactory())
362-
->create('ar_SA', \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE)
363-
->getPattern()
359+
'/(?<!d)d(?!d)/',
360+
'dd',
361+
preg_replace(
362+
'/[^MmDdYy\/\.\-]/',
363+
'',
364+
(new DateFormatterFactory())
365+
->create('ar_SA', \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE)
366+
->getPattern()
367+
)
364368
)
365369
],
366370
[Resolver::DEFAULT_LOCALE, self::DATE_FORMAT],

0 commit comments

Comments
 (0)