X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/baf33b39fcddb95d9289abd6b0529f2bffc89687..ea2811f6466500bc034b1c7a29a8ba75b1b490d4:/HTML/php/QuickForm/mdate.php diff --git a/HTML/php/QuickForm/mdate.php b/HTML/php/QuickForm/mdate.php index 18b3f6c..6be63e1 100644 --- a/HTML/php/QuickForm/mdate.php +++ b/HTML/php/QuickForm/mdate.php @@ -29,6 +29,7 @@ require_once('HTML/QuickForm/date.php'); require_once('Date.php'); +require_once('Validate.php'); /** * Class to dynamically create HTML Select elements from a date @@ -98,7 +99,29 @@ class HTML_QuickForm_mdate extends HTML_QuickForm_date */ function &getValue() { - return new Date (sprintf("%04d/%02d/%02d 00:00:00",$this->_selectedDate['y'],$this->_selectedDate['m'],$this->_selectedDate['d'])); - } // end func _createNumericOptionList + if ($this->_selectedDate['Y'] != 00) { + return new Date (sprintf("%04d-%02d-%02d 00:00:00",$this->_selectedDate['Y'],$this->_selectedDate['F'],$this->_selectedDate['d'])); + } + else { + return null; + } + } // end func getValue + + /** + * Verifica que una fecha sea valida. + * + * Verifica que una fecha sea valida. El formato siempre debe ser + * '%Y-%m-%d' + * + * @access public + * @return bool + */ + function validate($valor, $nombre, $formato = '') + { + if ($valor['Y'] != '--' && $valor['d'] != '--' && $valor['F'] != '--') { + return Validate::date($valor['Y'].'-'.$valor['d'].'-'.$valor['F'], array('format' => '%Y-%m-%d')); + } + return true; + } // end func validate } ?>