Fix date format handling

This commit is contained in:
Nathan Gray 2012-07-05 18:24:20 +00:00
parent 535051e77f
commit 6ae812ff45

View File

@ -70,12 +70,16 @@ class etemplate_widget_date extends etemplate_widget_transformer
$valid = (int)$value; $valid = (int)$value;
} }
// string with formatting letters like for php's date() method // string with formatting letters like for php's date() method
elseif (($obj = DateTime::createFromFormat($this->attrs['dataformat'], $value))) elseif (($valid = date($this->attrs['dataformat'], $value)))
{ {
$valid = $obj->format($this->attrs['dataformat']); // Nothing to do here
} }
// Null is acceptable also // Null is acceptable also
elseif ($value !== null) elseif ($value === null)
{
$valid = $value;
}
else
{ {
// this is not really a user error, but one of the clientside engine // this is not really a user error, but one of the clientside engine
self::set_validation_error($form_name,lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); self::set_validation_error($form_name,lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat);