Return, or update, current standard objects value.

@param null $value If $value is set, value is updated and DateTimeObject is returned.

@return mixed
165930
public function val($value = null)
    {
        if (!$this->isNull($value)) {
            $this->value = $value;

            return $this;
        }

        return $this->getDateObject()->format($this->format);
    }
1274141
protected function normalizeDateTime($value)
    {
        try {
            if (is_int($value)) {
                //timestamp
                $value = new DateTime("@$value");
            } elseif (!$value instanceof DateTime) {
                $value = new DateTime($value);
            }
        } catch (\Exception $e) {
            throw new InvalidArgumentException('Invalid date string provided', $e->getCode(), $e);
        }

        return $value;
    }
1262653
public function objectProperty($value)
    {
        switch (true) {
            case $value instanceof Int64:
                return [
                    'integerValue' => $value->get()
                ];

                break;
            case $value instanceof Blob:
                return [
                    'blobValue' => ($this->encode)
                        ? base64_encode((string) $value)
                        : (string) $value
                ];

                break;

            case $value instanceof \DateTimeInterface:
                return [
                    'timestampValue' => $value->format(self::DATE_FORMAT)
                ];

                break;

            case $value instanceof EntityInterface:
                return [
                    'entityValue' => $this->objectToRequest($value)
                ];

                break;

            case $value instanceof GeoPoint:
                return [
                    'geoPointValue' => $value->point()
                ];

                break;

            case $value instanceof Key:
                return [
                    'keyValue' => $value->keyObject()
                ];

                break;

            case $value instanceof \stdClass:
                return $this->convertArrayToEntityValue((array) $value);

            default:
                throw new \InvalidArgumentException(
                    sprintf('Value of type `%s` could not be serialized', get_class($value))
                );

                break;
        }
    }
214494
public static function convertToDb($value)
    {
        if (!is_array($value)) {
            return [];
        }

        // see DateType::convertToDatabaseValue()
        $convertor = function ($value) {
            if ($value === null || $value instanceof \MongoDate) {
                return $value;
            }

            try {
                $datetime = DateType::getDateTime($value);
                return new \MongoDate($datetime->format('U'), $datetime->format('u'));
            } catch (\InvalidArgumentException $e) {
                return null;
            }
        };

        return array_values(array_filter(array_map($convertor, $value)));
    }
312598
protected function getDateTimestamp($value)
    {
        if ($value instanceof DateTimeInterface) {
            return $value->getTimestamp();
        }

        if ($this->isTestingRelativeDateTime($value)) {
            $date = $this->getDateTime($value);

            if (! is_null($date)) {
                return $date->getTimestamp();
            }
        }

        return strtotime($value);
    }
479281
protected function valueRetriever($value)
    {
        if ($this->useAsCallable($value)) {
            return $value;
        }

        return function ($item) use ($value) {

            return ArrayHelper::dataGet($item, $value);
        };
    }
322874
private function processValue($value)
    {
        if ($value === "NOW()") {
            return $this->connection()->quote(gmdate("Y-m-d H:i:s"));
        } elseif ($value === "NULL") {
            return 'NULL';
        } elseif (is_array($value)) {
            return $this->connection()->quote(json_encode($value));
        } else {
            return $this->connection()->quote($value);
        }
    }
388043
public static function getTS($value = null)
	{
		if ($value === null)
		{
			return sfDateTimeToolkit::now();
		}
		else if ($value instanceof sfDate)
		{
			return $value->get();
		}
		else if (!is_numeric($value))
		{
			return strtotime($value);
		}
		else if (is_numeric($value))
		{
			return $value;
		}
		
		throw new sfDateTimeException(sprintf('A timestamp could not be retrieved from the value: %s', $value));
	}
892017
public function extract($value)
    {
        if ($value instanceof DateTime) {
            return $value->format($this->getFormat());
        }

        if ($this->nullable && $value === null) {
            return null;
        }

        throw new Exception\InvalidArgumentException(sprintf(
            'Invalid value: must be an instance of DateTime, "%s" given.',
            is_object($value) ? get_class($value) : gettype($value)
        ));
    }
447018
public function setValue($value = null)
    {
        if (is_callable($value)) {
            $value = call_user_func($value);
        }

        $value = $this->handleJsonType($value);

        $this->value = $value;

        return $this;
    }
1233674
function fromObject($value)
    {
        $this->clear();
        $this->orignalValue = $this->returnValue  = (string) (method_exists($value, '__toString') ? $value : null);
        return $this->parse();
    }
510605
public function getTypeFromValue($value = null)
    {
        $value = ($value == null ? $this->value : $value);
        return array_search($this->value, self::$sourceList);
    }
891343
public static function tryGetTypeForValue($value)
    {
        if (!is_object($value)) {
            return null;
        }

        // maybe it's a ValueObject

        // try get type name from types map
        $className = get_class($value);
        if (isset(self::$typesMap[$className])) {
            return Type::getType(self::$typesMap[$className]);
        }

        // use class name as type name
        $classNameParts = explode('\\', $className);
        $typeName = array_pop($classNameParts);

        if (array_key_exists($typeName, Type::getTypesMap())) {
            return Type::getType($typeName);
        }

        return null;
    }
109729
public static function getTypeValueFromObject( $value )
	{
		if ( $value instanceof XPath2Item )
		{
			return $value->getValueType();
		}

		if ( is_null( $value ) )
		{
			return Types::$NullType;
		}

		if ( is_array( $value ) )
		{
			return Types::$ArrayType;
		}

		if ( $value instanceof \DateTime )
		{
			return Types::$DateTimeValueType;
		}

		if ( is_bool( $value ) || $value instanceof FalseValue || $value instanceof TrueValue )
		{
			return Types::$BooleanType;
		}

		if ( is_string( $value ) )
		{
			return Types::$StringType;
		}

		if ( is_object( $value ) )
		{
			// if ( $value instanceof DateTimeInterval )
			// {
			// 	return Types::$DateTimeIntervalType;
			// }

			if ( $value instanceof DecimalValue )
			{
				return Types::$DecimalType;
			}

			if ( $value instanceof Long )
			{
				return Types::$LongType;
			}

			if ( $value instanceof DayTimeDurationValue )
			{
				return Types::$DayTimeDurationValueType;
			}

			if ( $value instanceof YearMonthDurationValue )
			{
				return Types::$YearMonthDurationValueType;
			}

			if ( $value instanceof UntypedAtomic )
			{
				return Types::$UntypedAtomicType;
			}

			if ( $value instanceof DurationValue )
			{
				return Types::$DurationValueType;
			}

			if ( $value instanceof GYearMonthValue )
			{
				return Types::$GYearMonthValueType;
			}

			if ( $value instanceof GYearValue )
			{
				return Types::$GYearValueType;
			}

			if ( $value instanceof GMonthValue )
			{
				return Types::$GMonthValueType;
			}

			if ( $value instanceof GMonthDayValue )
			{
				return Types::$GMonthDayValueType;
			}

			if ( $value instanceof GDayValue )
			{
				return Types::$GDayValueType;
			}

			if ( $value instanceof QNameValue )
			{
				return Types::$QNameValueType;
			}

			if ( $value instanceof HexBinaryValue )
			{
				return Types::$HexBinaryValueType;
			}

			if ( $value instanceof Base64BinaryValue )
			{
				return Types::$Base64BinaryValueType;
			}

			if ( $value instanceof IDREFSValue )
			{
				return Types::$IDREFSValueType;
			}

			if ( $value instanceof NMTOKENSValue )
			{
				return Types::$NMTOKENSValueType;
			}

			if ( $value instanceof ENTITIESValue )
			{
				return Types::$ENTITIESValueType;
			}

			$className = get_class( $value );

			if ( $className == Types::$NullType->getFullName() )
			{
				return Types::$NullType;
			}

			if ( $className == Types::$AnyUriValueType->getFullName() )
			{
				return Types::$AnyUriValueType;
			}

			if ( $className == Types::$UNION->getFullName() )
			{
				return Types::$UNION;
			}

			else if ( $className == Types::$BoolType->getFullName() )
				return Types::$BooType;
			else if ( $className == Types::$BooleanType->getFullName() )
				return Types::$BooleanType;
			else if ( $className == Types::$CharType->getFullName() )
				return Types::$CharType;
			else if ( $className == Types::$SByteType->getFullName() )
				return Types::$SByteType;
			else if ( $className == Types::$ByteType->getFullName() )
				return Types::$ByteType;
			else if ( $className == Types::$Int16Type->getFullName() )
				return Types::$Int16Type;
			else if ( $className == Types::$ShortType->getFullName() )
				return Types::$ShortType;
			else if ( $className == Types::$UInt16Type->getFullName() )
				return Types::$UInt16Type;
			else if ( $className == Types::$Int32Type->getFullName() )
				return Types::$Int32Type;
			else if ( $className == Types::$IntType->getFullName() )
				return Types::$IntType;
			else if ( $className == Types::$UInt32Type->getFullName() )
				return Types::$UInt32Type;
			else if ( $className == Types::$Int64Type->getFullName() )
				return Types::$Int64Type;
			else if ( $className == Types::$LongType->getFullName() )
				return Types::$LongType;
			else if ( $className == Types::$UInt64Type->getFullName() )
				return Types::$UInt64Type;
			else if ( $className == Types::$FloatType->getFullName() )
				return Types::$FloatType;
			else if ( $className == Types::$DoubleType->getFullName() )
				return Types::$DoubleType;
			else if ( $className == Types::$DateTimeIntervalType->getFullName() )
				return Types::$DateTimeIntervalType;
			else if ( $className == Types::$DecimalType->getFullName() )
				return Types::$DecimalType;
			else if ( $className == Types::$TimeValueType->getFullName() )
				return Types::$TimeValueType;
			else if ( $className == Types::$DateValueType->getFullName() )
				return Types::$DateValueType;
			else if ( $className == Types::$DateTimeValueType->getFullName() )
				return Types::$DateTimeValueType;
			else if ( $className == Types::$StringType->getFullName() )
				return Types::$StringType;
			else if ( $className == Types::$ArrayType->getFullName() )
				return Types::$ArrayType;
			else if ( $className == Types::$ObjectType->getFullName() )
				return Types::$ObjectType;
			else if ( $className == Types::$ArrayType->getFullName() )
				return Types::$ArrayType;
			else if ( $className == Types::$IntegerType->getFullName() )
				return Types::$IntegerType;

			return Type::FromNameAndTypeCode( $className, TypeCode::Object );
		}

		if ( is_double( $value ) || NAN . "" == strtoupper( $value ) )
		{
			return Types::$DoubleType;
		}

		if ( is_int( $value ) )
		{
			return Types::$IntType;
		}

	}
608965
public function reverseTransform($value): ?\DateTime
    {
        if ($value !== null && $value !== '' && \is_scalar($value)) {
            $date = new \DateTime();

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

        return null;
    }
918689
protected function valueRetriever($value)
	{
		return function($item) use ($value)
		{
			return is_object($item) ? $item->{$value} : array_get($item, $value);
		};
	}
343337
protected function getDataTypeByValue($value)
    {
        if(null === $value)
        {
            return \PDO::PARAM_NULL;
        }
        if(is_bool($value))
        {
            return \PDO::PARAM_BOOL;
        }
        if(is_int($value))
        {
            return \PDO::PARAM_INT;
        }
        return \PDO::PARAM_STR;
    }