function _datex_comment_edit_form_date_validate in Datex 7.3
Form element validation callback for comment form.
1 string reference to '_datex_comment_edit_form_date_validate'
- datex_form_alter in ./
datex.module - Implements hook_form_alter().
File
- ./
datex.module, line 385 - Datex main module file, Datex adds php-intl support to drupal.
Code
function _datex_comment_edit_form_date_validate($f, &$fs) {
$calendar = datex_factory();
if (!$calendar) {
return;
}
if (!isset($fs['values']['date'])) {
return;
}
$date =& $fs['values']['date'];
$m = [];
$pattern = '#^([0-9]{2,4})[-\\/\\\\]([0-9]{1,2})[-\\/\\\\]([0-9]{1,2})( {1,}([0-9]{1,2})\\:([0-9]{1,2}))?#';
$ok = preg_match($pattern, $date, $m);
if ($ok && count($m) == 7) {
$calendar
->setDateLocale($m[1], $m[2], $m[3]);
$calendar
->setTime($m[5], $m[6], 0);
$date = $calendar
->xFormat('Y-m-d H:i:s O');
}
else {
form_set_error('date', t('Invalid date'));
}
}