From c46f0d990ac840fc48d59c6cbc119664d56a7dca Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Wed, 20 May 2026 15:33:22 +0100 Subject: Replace deprecated strftime() with IntlDateFormatter in HtmlSelectDate strftime() was removed in PHP 8.2; use IntlDateFormatter('en_GB') with a regex to extract the month name, for PHP 8.5 compatibility. Co-Authored-By: Claude Sonnet 4.6 --- src/FunctionHandler/HtmlSelectDate.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/FunctionHandler/HtmlSelectDate.php b/src/FunctionHandler/HtmlSelectDate.php index a6acfb7b..83d512fa 100644 --- a/src/FunctionHandler/HtmlSelectDate.php +++ b/src/FunctionHandler/HtmlSelectDate.php @@ -273,6 +273,7 @@ class HtmlSelectDate extends Base { } // generate month if ($display_months) { + $dateFormatter = new \IntlDateFormatter('en_GB', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE); $_extra = ''; $_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month'); if ($all_extra) { @@ -301,12 +302,17 @@ class HtmlSelectDate extends Base { for ($i = 1; $i <= 12; $i++) { $_val = sprintf('%02d', $i); $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : - ($month_format === '%m' ? $_val : @strftime($month_format, $_month_timestamps[$i])); - $_value = $month_value_format === '%m' ? $_val : @strftime($month_value_format, $_month_timestamps[$i]); + ($month_format === '%m' ? $_val : $dateFormatter->format($_month_timestamps[$i])); + $pattern = '/\d{1,2}\s+([a-zA-ZáéíóúüñÁÉÍÓÚÜÑ]+)\s+\d{4}/u'; + // Match the pattern + if (preg_match($pattern, $_text, $matches)) { + // The month part is in the first capturing group + $_text = $matches[1] ?? $_val; + } + $_value = $month_value_format === '%m' ? $_val : $dateFormatter->format($_month_timestamps[$i]); $_html_months .= '' . $option_separator; - } - $_html_months .= ''; + } $_html_months .= ''; } // generate day if ($display_days) { -- cgit v1.3