Skip to content

Commit 6c30b0b

Browse files
committed
Merge remote-tracking branch 'origin/ACP2E-4344' into PR_2025_12_11_muntianu
2 parents f6d46b2 + 041cb3c commit 6c30b0b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

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

Lines changed: 31 additions & 1 deletion
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
/**
@@ -171,6 +172,8 @@ protected function getFormFilter()
171172
/**
172173
* Apply output filter to value
173174
*
175+
* Normalizes date to display format with standard numerals to avoid localized numerals (e.g., Arabic)
176+
*
174177
* @param string $value
175178
* @return string
176179
*/
@@ -181,7 +184,7 @@ protected function applyOutputFilter($value)
181184
$value = date('Y-m-d', $this->getTime());
182185
$value = $filter->outputFilter($value);
183186
}
184-
return $value;
187+
return $this->normalizedDobOutput($value);
185188
}
186189

187190
/**
@@ -462,4 +465,31 @@ private function setTwoMonthPlaces(string $format): string
462465
$format
463466
);
464467
}
468+
469+
/**
470+
* Normalize the dob for a proper output on the frontend
471+
*
472+
* Converts localized date format (with potentially localized numerals like Arabic) to standard numerals
473+
*
474+
* @param mixed $value
475+
* @return mixed
476+
*/
477+
private function normalizedDobOutput(mixed $value): mixed
478+
{
479+
if (empty($value)) {
480+
return $value;
481+
}
482+
$locale = $this->localeResolver->getLocale();
483+
$dateFormat = $this->getDateFormat();
484+
$dateTime = $this->_localeDate->date($value, $locale, false, false);
485+
$formatter = new \IntlDateFormatter(
486+
Resolver::DEFAULT_LOCALE,
487+
\IntlDateFormatter::NONE,
488+
\IntlDateFormatter::NONE,
489+
$dateTime->getTimezone(),
490+
null,
491+
$dateFormat
492+
);
493+
return $formatter->format($dateTime);
494+
}
465495
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ public static function setDateDataProvider()
281281
['31/12/1999', strtotime('1999-12-31'), '31/12/1999', 'fr_FR'],
282282
['1999-12-31', strtotime('1999-12-31'), '31/12/1999', 'fr_FR'],
283283
['31 Décembre 1999', strtotime('1999-12-31'), '31/12/1999', 'fr_FR'],
284+
['١٠/١٠/٢٠٠٦', strtotime('2006-10-10'), '10/10/2006', 'ar_SA'],
284285
];
285286
}
286287

0 commit comments

Comments
 (0)