form : add the conversion format for dates

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2765 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-06-27 09:24:22 +00:00
parent 75499a6639
commit 4c470b9306

View File

@@ -301,6 +301,24 @@ class form
}
return $errors;
}
/** Convert Date received in one format to another.
* If the provided string is not corresponding to the format, don't change
* anything.
* Format used http://php.net/manual/en/datetime.createfromformat.php
* @param string $inputDate
* @param string $inputFormat
* @param string $outputFormat
* @return string
*/
public function convertDate ($inputDate, $inputFormat, $outputFormat)
{
$date = DateTime::CreateFromFormat ($inputFormat, $inputDate);
$errors = $date->getLastErrors();
if ($errors["warning_count"] > 0 || $errors["error_count"] > 0)
return $inputDate;
return $date->format ($outputFormat);
}
}
/** the definition of a formfield */