summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorSimon Wisselink <wisskid@users.noreply.github.com>2022-09-22 14:11:36 +0200
committerGitHub <noreply@github.com>2022-09-22 14:11:36 +0200
commitc53342c9fc9fb00e440a00a549e4076b688c808b (patch)
treefc79c980e00398725a9707f5fb7c81947b237feb /libs
parentf8a958cd537fbec6a4cf8d459d0c5e7be15d6248 (diff)
downloadsmarty-c53342c9fc9fb00e440a00a549e4076b688c808b.tar.gz
smarty-c53342c9fc9fb00e440a00a549e4076b688c808b.tar.bz2
smarty-c53342c9fc9fb00e440a00a549e4076b688c808b.zip
Silence deprecation errors for strtime in PHP8.1 or higher
Fixes #672 (#811)
Diffstat (limited to 'libs')
-rw-r--r--libs/plugins/function.html_select_date.php4
-rw-r--r--libs/plugins/modifier.date_format.php3
2 files changed, 4 insertions, 3 deletions
diff --git a/libs/plugins/function.html_select_date.php b/libs/plugins/function.html_select_date.php
index a396046b..d9c57197 100644
--- a/libs/plugins/function.html_select_date.php
+++ b/libs/plugins/function.html_select_date.php
@@ -316,8 +316,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
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 : @strftime($month_format, $_month_timestamps[ $i ]));
+ $_value = $month_value_format === '%m' ? $_val : @strftime($month_value_format, $_month_timestamps[ $i ]);
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}
diff --git a/libs/plugins/modifier.date_format.php b/libs/plugins/modifier.date_format.php
index 8e7e0b6e..e3589fd0 100644
--- a/libs/plugins/modifier.date_format.php
+++ b/libs/plugins/modifier.date_format.php
@@ -78,7 +78,8 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
}
$format = str_replace($_win_from, $_win_to, $format);
}
- return strftime($format, $timestamp);
+ // @ to suppress deprecation errors when running in PHP8.1 or higher.
+ return @strftime($format, $timestamp);
} else {
return date($format, $timestamp);
}