Fix non-iso dates

@param string $value
@return string
556602
protected function fixInputDate($value)
    {
        // split
        list($year, $month, $day, $time) = $this->explodeDateString($value);

        if ((int)$year === 0 && (int)$month === 0 && (int)$day === 0) {
            return null;
        }
        // Validate date
        if (!checkdate($month, $day, $year)) {
            throw new InvalidArgumentException(
                "Invalid date: '$value'. Use " . self::ISO_DATE . " to prevent this error."
            );
        }

        // Convert to y-m-d
        return sprintf('%d-%02d-%02d%s', $year, $month, $day, $time);
    }
171929
private static function transformValue($value)
    {
        if (is_null($value)) {
            return $value;
        }

        if ($value instanceof PrimalValued) {
            $value = $value->toPrimitive();
        } elseif ($value instanceof Arrayable) {
            $value = $value->toArray();
            if (empty($value)) {
                $value = null;
            }
        } elseif (is_array($value)) {
            $value = array_map(function ($arrValue) {
                return self::transformValue($arrValue);
            }, $value);
        } elseif ($value instanceof \DateTimeZone) {
            $value = $value->getName();
        } elseif ($value instanceof Carbon) {
            $value = $value->toRfc3339String();
        }

        return $value;
    }
1305362
public function convertToDate($value) {

		foreach($this -> date_formats as $format) {

			if(false !== \DateTime :: createFromFormat($format, $value)) {

				$d = new DateTime($value);
				$d -> createFromFormat($format, $value);

				if($d && $d -> format($format) == $value) {

					$d -> saveFormat($format);
					return $d;
				}
			}
		}

		return $value;
	}
661103
function EscapeValue($value)
    {
        if ($value === null)
            return 'NULL';
        
        if ($value instanceof Date)
            $value = $value->ToString( 'Y-m-d H:i:s');

        return "'" . $this->db->real_escape_string($value) . "'";
    }
41250
public static function date(string $value): bool
    {
        $matches = preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value);
        return is_int($matches) && $matches > 0;
    }
629261
public function filter($value)
    {
	    if (is_string($value))
	        return new DateTime('@'.strtotime($value));
	    if ($value instanceof DateTime)
		    return $value;
	    if (is_int($value))
		    return new DateTime('@'.$value);
	    return null;
    }
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
            );
        }
    }
913115
public function format($value)
  {
    if ($value===null) return null;

    $match = preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $parts);
    $valid = ($match && checkdate((int)$parts[2], (int)$parts[3], (int)$parts[1]));
    if ($valid)
    {
      if ($value===$this->openDate) return '';

      $date = new \DateTime($value);

      return $date->format($this->format);
    }

    return $value;
  }
1198624
private static function _parseTwoDateTimeStrings($value)
    {
        $dateStrings = explode(',', $value);
        if (count($dateStrings) !== 2)
            return null;

        $timestamps = [];

        foreach ($dateStrings as $dateString) {
            $result = @preg_match('/^\d\d\d\d-\d?\d-\d?\d \d\d:\d\d:\d\d$/', $dateString);
            if ($result !== 1)
                return null;
            $timestamp = strtotime($dateString);
            if ($timestamp === false)
                return null;

            $timestamps[] = $timestamp;
        }
        return $timestamps;
    }
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;
    }
876970
public function checkDate($value)
    {

        if ($value instanceof PointInTimeContract) {
            return $value->isValid();
        }

        if ($value instanceof DateTimeInterface) {
            return true;
        }

        // Support for legacy datetime objects like Zend_Date
        if (is_object($value) && method_exists($value, 'getTimestamp')) {
            return $this->checkInt($value->getTimestamp());
        }

        if ((!Type::isStringLike($value) && !is_numeric($value)) || strtotime($value) === false) {
            return false;
        }

        $date = date_parse($value);

        return checkdate($date['month'], $date['day'], $date['year']);
    }
183606
protected function convert_to_date_time( $value ) {

		if ( $value instanceof \DateTimeInterface ) {
			return $value;
		}

		switch ( gettype( $value ) ) {
			case 'string' :
				return $this->convert_string( $value );
			case 'integer' :
				return $this->convert_integer( $value );
			case 'double' :
				return $this->convert_double( $value );
			case 'array' :
				return $this->convert_array( $value );
		}

		$this->error_code = Error\ErrorLoggerInterface::INVALID_TYPE_NON_DATE;

		return FALSE;
	}
838321
public static function createFromInput($value)
    {
        $timestamp = strtotime($value);

        try {
            // trim java ms
            $value = preg_replace('`(\\.[0-9]{3})\\+`', '+', $value);

            $datetime = self::createFromFormat(self::DATE_FORMAT, $value);

            if ($timestamp != $datetime->getTimestamp()) {
                throw new ResponseCode("Invalid datetime with value '$value'", 422);
            }
        } catch (\Exception $exception) {
            throw new ResponseCode("Invalid datetime format with value '$value'", 422);
        }

        return $datetime;
    }
365655
private function fixValue(string $value)
    {
        if ('' === $value) {
            return null;
        }

        if ('true' === $value) {
            return true;
        }

        if ('false' === $value) {
            return false;
        }

        if (is_numeric($value) && '0' !== $value[0]) {
            if ((string) (int) $value === $value) {
                return (int) $value;
            }

            return (float) $value;
        }

        return $value;
    }
678661
public function reverseTransform($value)
    {
        if ( $value['date'] && $value['time'] ) {
            return new \DateTime(sprintf(
                '%s %s',
                $value['date']->format('Y-m-d'),
                $value['time']->format('H:i:s')
            ));
        }
        if ( $value['date'] ) {
            return new \DateTime(sprintf(
                '%s',
                $value['date']->format('Y-m-d')
            ));
        }
        if ( $value['time'] ) {
            return new \DateTime(sprintf(
                '%s',
                $value['time']->format('H:i:s')
            ));
        }
        return null;
    }
1197030
public static function unescapeValue($value)
    {
        $callback = function ($matches) {
            return chr(hexdec($matches[1]));
        };

        return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', $callback, $value);
    }
320271
public function parseValue($value)
    {
        $date = \DateTime::createFromFormat(DATE_ATOM, $value);
        if (!$date) {
            throw new Error(sprintf("Cannot represent following value as date: %s", Utils::printSafeJson($value)));
        }

        return $date;
    }