From a3abbeb4a51c9b80400353eb42b5f6ade2e5e587 Mon Sep 17 00:00:00 2001 From: Jeroen Versteeg Date: Mon, 5 Jun 2023 13:32:40 +0200 Subject: [PATCH] Fix IntlExtension::formatDateTime uses prototype pattern if set See https://github.com/twigphp/intl-extra/pull/7 for details --- extra/intl-extra/IntlExtension.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extra/intl-extra/IntlExtension.php b/extra/intl-extra/IntlExtension.php index 955d6ec9233..8b12fdd189c 100644 --- a/extra/intl-extra/IntlExtension.php +++ b/extra/intl-extra/IntlExtension.php @@ -423,7 +423,13 @@ private function createDateFormatter(?string $locale, ?string $dateFormat, ?stri $timeFormatValue = $timeFormatValue ?: $this->dateFormatterPrototype->getTimeType(); $timezone = $timezone ?: $this->dateFormatterPrototype->getTimeType(); $calendar = $calendar ?: $this->dateFormatterPrototype->getCalendar(); - $pattern = $pattern ?: $this->dateFormatterPrototype->getPattern(); + if ('' === $pattern) { + if (!$dateFormat && !$timeFormat) { // no explicit values for either format given + $pattern = $this->dateFormatterPrototype->getPattern(); + } else { + $pattern = null; + } + } } $hash = $locale.'|'.$dateFormatValue.'|'.$timeFormatValue.'|'.$timezone->getName().'|'.$calendar.'|'.$pattern;