From de9bdb48a7058d7c215187e99e2a9c1c4d43f751 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Sat, 5 Dec 2026 04:15:25 +0100 Subject: [PATCH] Replace twig_date_converter deprecated in twig 3.9 Use DateTimeInterface to allow DateTime and DateTimeImmutable dates --- Util/IntlUtil.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Util/IntlUtil.php b/Util/IntlUtil.php index 52bd546..22d31f0 100644 --- a/Util/IntlUtil.php +++ b/Util/IntlUtil.php @@ -11,8 +11,9 @@ namespace Rapsys\PackBundle\Util; -use Twig\Error\SyntaxError; use Twig\Environment; +use Twig\Error\SyntaxError; +use Twig\Extension\CoreExtension; /** * Manages intl conversions @@ -32,9 +33,10 @@ class IntlUtil { /** * Format date */ - public function date(Environment $env, \DateTime $date, string $dateFormat = 'medium', string $timeFormat = 'medium', ?string $locale = null, \IntlTimeZone|\DateTimeZone|string|null $timezone = null, ?string $calendar = null, ?string $pattern = null) { + public function date(Environment $env, \DateTimeInterface $date, string $dateFormat = 'medium', string $timeFormat = 'medium', ?string $locale = null, \IntlTimeZone|\DateTimeZone|string|null $timezone = null, ?string $calendar = null, ?string $pattern = null) { //Get converted date - $date = twig_date_converter($env, $date, $timezone); + //XXX: was twig_date_converter($env, $date, $timezone) before it went deprecated in twig 3.9 + $date = $env->getExtension(CoreExtension::class)->convertDate($date, $timezone); //Set date and time formatters $formatters = [ -- 2.52.1