Transforms a DateRange into a string.

@param DateRange $value DateRange value.

@return string string value.
513511
public function transform($value)
    {
        if ( $value ) {
            $from = '';
            if ( $value->getFrom() ) {
                $from = $value->getFrom()->format('Y-m-d');
            }
            $to = '';
            if ( $value->getTo() ) {
                $to = $value->getTo()->format('Y-m-d');
            }
            return sprintf(
                '%s%s%s',
                $from,
                $this->dateSeparator,
                $to
            );
        }
    }
503506
protected function interpretAsDate($value)
    {
        if (null === $value || 0 === $value || '' === $value) {
            return null;
        }

        if ($value instanceof DateTime) {
            return $value;
        }

        if (is_string($value)) {
            return new Carbon($value);
        }

        if (is_numeric($value)) {
            return Carbon::createFromTimestamp($value);
        }

        throw new UnexpectedValueException("Expecting null or date");
    }
1009062
public static function convertToEdmDateTime($value)
    {
        if (empty($value)) {
            return $value;
        }

        if (is_string($value)) {
            $value = self::convertToDateTime($value);
        }

        Validate::isDate($value, 'value');

        $cloned = clone $value;
        $cloned->setTimezone(new \DateTimeZone('UTC'));

        return str_replace('+0000', 'Z', $cloned->format(\DateTime::ISO8601));
    }
608965
public function reverseTransform($value): ?\DateTime
    {
        if ($value !== null && $value !== '' && \is_scalar($value)) {
            $date = new \DateTime();

            return $date->setTimestamp((int) $value);
        }

        return null;
    }
362098
public function toPlatformValue($value)
    {
        $datetime = $this->toDateTimeObject($value);
        $format = $this->getFormat();
        
        if (strpos($format, '%') !== false) {
            return strftime($format, $datetime->getTimestamp());
        }
        
        return $datetime->format($format);
    }
108556
private function toDateTimeObject($value)
    {
        $datetime = null;
        
        switch (true) {
            case $value instanceof \DateTime:
                $datetime = new DateTime($value->format(\DateTime::RFC3339));
                break;
            case is_numeric($value):
                $datetime = new DateTime(sprintf('@%d', $value));
                break;
            case is_string($value):
                $datetime = new DateTime($value);
                break;
        }
        
        return $datetime;
    }
659048
protected function transformValue($value)
    {
        // first of all remove any quotation marks
        $value = preg_replace('/("|\')(.+)("|\')/', '$2', $value);

        $this->transformToDate($value);
        $this->transformToFloat($value);
        $this->transformToInt($value);

        return $value;
    }
1365128
protected function dataTransform(&$value)
    {
        if (is_object($value)) {

            // Convert dates to the settings for date_format.
            if (($dateFormat = $this->getSettings()->dateFormat) && $value instanceof \DateTime) {
                $value = $value->format($dateFormat);
            }

            // Handle other objects as needed.
            if (method_exists($this, 'objectHandler')) {
                $value = $this->objectHandler($key, $value);
            }
        }
    }
1297534
public function marshal($value)
    {
        $date = parent::marshal($value);
        if ($date instanceof DateTime) {
            $date->setTime(0, 0, 0);
        }

        return $date;
    }
1198516
public function filter($value)
    {
        if ($value === '' || $value === null) {
            return $value;
        }

        if (!is_string($value) && !is_int($value) && !$value instanceof DateTime) {
            return $value;
        }

        /**
         * We try to create a \DateTime according to the format. If the creation fails, we return the string itself.
         * So it's treated by Validate\Date
         */
        $date = is_int($value) ? date_create("@$value") // from timestamp
            : PhpDateTime::createFromFormat($this->format, $value);

        // Invalid dates can show up as warnings (ie. "2007-02-99") and still return a DateTime object
        $errors = PhpDateTime::getLastErrors();

        if ($date === false || (array_key_exists('warning_count', $errors) && $errors['warning_count'] > 0)) {
            return $value;
        }

        return DateTime::instance($date);
    }
474330
protected function convert_string( $value ) {

		$format = $this->input_data[ 'format' ];
		$date   = \DateTime::createFromFormat( $format, $value );

		// Invalid dates can show up as warnings (ie. "2007-02-99") and still return a DateTime object.
		$errors = \DateTime::getLastErrors();
		if ( $errors[ 'warning_count' ] > 0 ) {
			$this->error_code = Error\ErrorLoggerInterface::INVALID_DATE_FORMAT;

			return FALSE;
		}

		return $date;
	}
845167
protected function toString($value)
    {
        if (is_numeric($value)) {
            return "$value";
        }
        if ($value === true) {
            return 'true';
        }
        if ($value === false) {
            return 'false';
        }
        if (is_null($value)) {
            return '';
        }
        if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
            return $this->toString(reset($value));
        }

        return $value;
    }
822059
protected function valueToString($value) : string
    {
        if ($value === null) {
            $def_value = 'null';
        } elseif ($value === false) {
            $def_value = 'false';
        } elseif ($value === true) {
            $def_value = 'true';
        } elseif (is_string($value)) {
            $def_value = '"' . str_replace('"', '\\"', $value) . '"';
        } elseif (is_numeric($value)) {
            $def_value = '' . $value;
        }

        return $def_value;
    }
759179
private function prepareValue($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        if (strpos($value, "\n") !== false) {
            $values = explode("\n", $value);
            foreach ($values as &$line) {
                $line = $this->getIndentation(8) . $line;
            }
            $value = implode("\n", $values);

            return "|\n" . $value;
        }

        return '\'' . str_replace('\'', '\'\'', $value) . '\'';
    }
1199123
protected function normalize_date_time( $value ) {

		if ( $value === '' || $value === NULL ) {
			return $value;
		}
		if ( ! is_string( $value ) && ! is_int( $value ) && ! $value instanceof DateTime ) {
			return $value;
		}
		if ( is_int( $value ) ) {
			//timestamp
			$value = new \DateTime( '@' . $value );
		} elseif ( ! $value instanceof DateTime ) {
			$value = new \DateTime( $value );
		}

		return $value->format( $this->options[ 'format' ] );
	}
901516
public function formatTimeago($value)
    {
        if ($value instanceof DateTime) {
            $value = date_timestamp_get($value);

        } else if (!is_numeric($value) && is_string($value)) {
            $value = strtotime($value);
        }

        return $this->inWords((time() - $value));
    }
466540
public function isInRange($dateValue, $value)
    {
        $parts = array_map('trim', explode('-', $value, 2));

        return $dateValue >= $parts[0] && $dateValue <= $parts[1];
    }