Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/formatters/date_formatter.php
Show First 20 Lines • Show All 367 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
/** | /** | ||||
* Converts formatted date+time to timestamp and validates format | * Converts formatted date+time to timestamp and validates format | ||||
* | * | ||||
* @param mixed $value | * @param mixed $value | ||||
* @param string $field_name | * @param string $field_name | ||||
* @param kDBItem $object | * @param kDBItem $object | ||||
* @param string $format Format. | |||||
* @return mixed | * @return mixed | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function Parse($value, $field_name, &$object) | public function Parse($value, $field_name, &$object, $format = null) | ||||
{ | { | ||||
$options = $object->GetFieldOptions($field_name); | $options = $object->GetFieldOptions($field_name); | ||||
$dt_separator = getArrayValue($options,'date_time_separator'); | $dt_separator = getArrayValue($options,'date_time_separator'); | ||||
if($dt_separator) $value = trim($value, $dt_separator); | if($dt_separator) $value = trim($value, $dt_separator); | ||||
if($value == '') return NULL; | if($value == '') return NULL; | ||||
//return strtotime($value); | //return strtotime($value); | ||||
if ( !isset($format) ) { | |||||
$format = $options['input_format']; | $format = $options['input_format']; | ||||
} | |||||
if ($dt_separator) $format = trim($format, $dt_separator); | if ($dt_separator) $format = trim($format, $dt_separator); | ||||
$error_params = array( | $error_params = array( | ||||
'format' => $this->HumanFormat($format), | 'format' => $this->HumanFormat($format), | ||||
'sample' => adodb_date($format), | 'sample' => adodb_date($format), | ||||
'value' => $value, | 'value' => $value, | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |