* day values (Marcus Bointon)
* - 1.3.2 support negative timestamps, force year
* dropdown to include given date unless explicitly set (Monte)
+ * - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that
+ * of 0000-00-00 dates (cybot, boots)
* @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
- * @version 1.3.2
+ * @version 1.3.4
* @author Andrei Zmievski
* @author Monte Ohrt <monte at ohrt dot com>
* @param array
}
}
- if(preg_match('!^-\d+$!',$time)) {
+ if (preg_match('!^-\d+$!', $time)) {
// negative timestamp, use date()
- $time = date('Y-m-d',$time);
+ $time = date('Y-m-d', $time);
}
// If $time is not in format yyyy-mm-dd
- if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
+ if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) {
+ $time = $found[1];
+ } else {
// use smarty_make_timestamp to get an unix timestamp and
// strftime to make yyyy-mm-dd
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
}
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);
-
+
// make syntax "+N" or "-N" work with start_year and end_year
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
if ($match[1] == '+') {
$start_year = strftime('%Y') - $match[2];
}
}
- if (strlen($time[0]) > 0) {
+ if (strlen($time[0]) > 0) {
if ($start_year > $time[0] && !isset($params['start_year'])) {
// force start year to include given date if not explicitly set
$start_year = $time[0];
$html_result = $month_result = $day_result = $year_result = "";
+ $field_separator_count = -1;
if ($display_months) {
+ $field_separator_count++;
$month_names = array();
$month_values = array();
if(isset($month_empty)) {
}
if ($display_days) {
+ $field_separator_count++;
$days = array();
if (isset($day_empty)) {
$days[''] = $day_empty;
}
if ($display_years) {
+ $field_separator_count++;
if (null !== $field_array){
$year_name = $field_array . '[' . $prefix . 'Year]';
} else {
break;
}
// Add the field seperator
- if($i != 2) {
+ if($i < $field_separator_count) {
$html_result .= $field_separator;
}
}