From 7169e594c4172db0e2d94faf122691a38657b730 Mon Sep 17 00:00:00 2001 From: rodneyrehm Date: Thu, 6 Oct 2011 15:12:35 +0000 Subject: [PATCH] - bugfix start_year and end_year of {html_select_date} did not use current year as offset base (Issue #53) --- change_log.txt | 1 + libs/plugins/function.html_select_date.php | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/change_log.txt b/change_log.txt index da9e9b4b..12f5aa2a 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@ ===== trunk ===== 06.10.2011 - bugfix switch lexer internals depending on mbstring.func_overload +- bugfix start_year and end_year of {html_select_date} did not use current year as offset base (Issue #53) 05.10.2011 - bugfix of problem introduced with r4342 by replacing strlen() with isset() diff --git a/libs/plugins/function.html_select_date.php b/libs/plugins/function.html_select_date.php index 93a37d74..16844052 100644 --- a/libs/plugins/function.html_select_date.php +++ b/libs/plugins/function.html_select_date.php @@ -55,7 +55,9 @@ function smarty_function_html_select_date($params, $template) { // generate timestamps used for month names only static $_month_timestamps = null; + static $_current_year = null; if ($_month_timestamps === null) { + $_current_year = date('Y'); $_month_timestamps = array(); for ($i = 1; $i <= 12; $i++) { $_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000); @@ -211,11 +213,11 @@ function smarty_function_html_select_date($params, $template) $key .= '_year'; $t = $$key; if ($t === null) { - $$key = (int)$_year; + $$key = (int)$_current_year; } else if ($t[0] == '+') { - $$key = (int)($_year + trim(substr($t, 1))); + $$key = (int)($_current_year + trim(substr($t, 1))); } else if ($t[0] == '-') { - $$key = (int)($_year - trim(substr($t, 1))); + $$key = (int)($_current_year - trim(substr($t, 1))); } else { $$key = (int)$$key; }