correctly handle partially empty dates (like "2004--" or "-12-").

This commit is contained in:
messju
2004-02-13 23:38:08 +00:00
parent 1ce846e1b3
commit 0548fee520
2 changed files with 6 additions and 4 deletions

2
NEWS
View File

@@ -1,3 +1,5 @@
- fix allow empty years, months and days in html_select_date's
time-attribute (messju)
- fix YES and NO should not be booleanized inside triple-quotes in a
config-file (messju)
- fix accidently slurped line following a triple-quoted value in a

View File

@@ -123,7 +123,7 @@ function smarty_function_html_select_date($params, &$smarty)
}
// If $time is not in format yyyy-mm-dd
if (!preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $time) && $time!='--') {
if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
// then $time is empty or unix timestamp or mysql timestamp
// using smarty_make_timestamp to get an unix timestamp and
// strftime to make yyyy-mm-dd
@@ -160,8 +160,8 @@ function smarty_function_html_select_date($params, &$smarty)
$month_values[''] = '';
}
for ($i = 1; $i <= 12; $i++) {
$month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
$month_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
$month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
$month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
$month_result .= '<select name=';
@@ -183,7 +183,7 @@ function smarty_function_html_select_date($params, &$smarty)
$month_result .= smarty_function_html_options(array('output' => $month_names,
'values' => $month_values,
'selected' => $month_values[$time[1]-1],
'selected' => $month_values[(int)$time[1]],
'print_result' => false),
$smarty);