From bc5ba1157f9bd8759cdf033405e0738716310ce4 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Wed, 18 Sep 2024 23:40:37 +0200 Subject: [PATCH] CalendarField: changing strftime to date --- libraries/src/Form/Field/CalendarField.php | 3 ++- libraries/src/HTML/HTMLHelper.php | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libraries/src/Form/Field/CalendarField.php b/libraries/src/Form/Field/CalendarField.php index 0c72d801cfa23..fa1d9cd04226e 100644 --- a/libraries/src/Form/Field/CalendarField.php +++ b/libraries/src/Form/Field/CalendarField.php @@ -11,6 +11,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Form\FormField; +use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\Registry\Registry; @@ -320,7 +321,7 @@ protected function getInput() $date = \DateTimeImmutable::createFromFormat('U', strtotime($value)); $value = $date->format($this->filterFormat); } else { - $value = strftime($this->format, strtotime($value)); + $value = date(HTMLHelper::strftimeFormatToDateFormat($this->format), strtotime($value)); } date_default_timezone_set($tz); diff --git a/libraries/src/HTML/HTMLHelper.php b/libraries/src/HTML/HTMLHelper.php index aeb74f1266eaf..558a7aeb20402 100644 --- a/libraries/src/HTML/HTMLHelper.php +++ b/libraries/src/HTML/HTMLHelper.php @@ -1271,6 +1271,18 @@ public static function strftimeFormatToDateFormat(string $strftimeformat) '%H', '%M', '%S', + '%a', + '%A', + '%e', + '%j', + '%u', + '%w', + '%W', + '%b', + '%B', + '%h', + '%g', + '%I', ], [ 'Y', @@ -1279,6 +1291,18 @@ public static function strftimeFormatToDateFormat(string $strftimeformat) 'H', 'i', 's', + 'D', + 'l', + 'j', + 'z', + 'N', + 'w', + 'W', + 'M', + 'F', + 'M', + 'y', + 'h', ], $strftimeformat );