Skip to content

Commit 9a2c223

Browse files
committed
ACP2E-4344: Error Invalid date when updating account information
1 parent d9fc027 commit 9a2c223

File tree

1 file changed

+14
-18
lines changed
  • app/code/Magento/Customer/Block/Widget

1 file changed

+14
-18
lines changed

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\Json\EncoderInterface;
1212
use Magento\Framework\Locale\Bundle\DataBundle;
13+
use Magento\Framework\Locale\Resolver;
1314
use Magento\Framework\Locale\ResolverInterface;
1415

1516
/**
@@ -468,32 +469,27 @@ private function setTwoMonthPlaces(string $format): string
468469
/**
469470
* Normalize the dob for a proper output on the frontend
470471
*
472+
* Converts localized date format (with potentially localized numerals like Arabic) to standard numerals
473+
*
471474
* @param bool|string|null $value
472475
* @return bool|string
473476
*/
474477
private function normalizedDobOutput(bool|string|null $value): bool|string
475478
{
476-
if ($value === false || $value === null) {
477-
return false;
479+
if (empty($value)) {
480+
return $value;
478481
}
479482
$locale = $this->localeResolver->getLocale();
480483
$dateFormat = $this->getDateFormat();
481-
$formatter = new \IntlDateFormatter(
482-
$locale,
483-
\IntlDateFormatter::SHORT,
484-
\IntlDateFormatter::NONE
484+
$dateTime = $this->_localeDate->date($value, $locale, false, false);
485+
486+
return $this->_localeDate->formatDateTime(
487+
$dateTime,
488+
\IntlDateFormatter::NONE,
489+
\IntlDateFormatter::NONE,
490+
Resolver::DEFAULT_LOCALE,
491+
null,
492+
$dateFormat
485493
);
486-
$formatter->setPattern($dateFormat);
487-
$timestamp = $formatter->parse($value);
488-
if ($timestamp !== false) {
489-
$formatterEn = new \IntlDateFormatter(
490-
'en',
491-
\IntlDateFormatter::SHORT,
492-
\IntlDateFormatter::NONE
493-
);
494-
$formatterEn->setPattern($dateFormat);
495-
$value = $formatterEn->format($timestamp);
496-
}
497-
return $value;
498494
}
499495
}

0 commit comments

Comments
 (0)