/** * {@inheritdoc} * */ public function setDataValue($input, DataField &$dataField, array $options) { $format = DateRangeFieldType::convertJavascriptDateFormat($options['displayOptions']['locale']['format']); $inputs = explode(' - ', $input); if (count($inputs) == 2) { $convertedDates = []; $fromConverted = \DateTime::createFromFormat($format, $inputs[0]); if ($fromConverted) { $convertedDates[$options['mappingOptions']['fromDateMachineName']] = $fromConverted->format(\DateTime::ISO8601); } $toConverted = \DateTime::createFromFormat($format, $inputs[1]); if ($toConverted) { $convertedDates[$options['mappingOptions']['toDateMachineName']] = $toConverted->format(\DateTime::ISO8601); } $dataField->setRawData($convertedDates); } else { //TODO: log warnign } }
public function convertJavascriptDateFormat($format) { return DateRangeFieldType::convertJavascriptDateFormat($format); }