cvs: smarty / NEWS /libs/plugins function.html_select_date.php

From: Date: Wed, 01 Nov 2006 20:35:08 +0000
Subject: cvs: smarty / NEWS /libs/plugins function.html_select_date.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-2164@lists.php.net to get a copy of this message
boots Wed Nov 1 20:35:08 2006 UTC Modified files: /smarty NEWS /smarty/libs/plugins function.html_select_date.php Log: make html_select_date work consistently with 0000-00-00 00:00:00 and 0000-00-00 inputs Thanks to cybot from forums http://cvs.php.net/viewvc.cgi/smarty/NEWS?r1=1.539&r2=1.540&diff_format=u Index: smarty/NEWS diff -u smarty/NEWS:1.539 smarty/NEWS:1.540 --- smarty/NEWS:1.539 Fri Aug 25 19:21:27 2006 +++ smarty/NEWS Wed Nov 1 20:35:07 2006 @@ -1,3 +1,5 @@ +- make html_select_date work consistently with 0000-00-00 00:00:00 and + 0000-00-00 inputs (cybot, boots) - fix wrong handling of insert's name attribute. (messju) - fix false replacement of "$t" inside double quotes (checat, messju) - added support for column headings and caption element to html_table and http://cvs.php.net/viewvc.cgi/smarty/libs/plugins/function.html_select_date.php?r1=1.34&r2=1.35&diff_format=u Index: smarty/libs/plugins/function.html_select_date.php diff -u smarty/libs/plugins/function.html_select_date.php:1.34 smarty/libs/plugins/function.html_select_date.php:1.35 --- smarty/libs/plugins/function.html_select_date.php:1.34 Tue Apr 4 16:24:13 2006 +++ smarty/libs/plugins/function.html_select_date.php Wed Nov 1 20:35:08 2006 @@ -24,9 +24,11 @@ * 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 @@ -131,19 +133,21 @@ } } - 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] == '+') { @@ -159,7 +163,7 @@ $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];

« previous php.smarty.cvs (#2164) next »