public static function ToInt( $value, $provider = null )
	{
		if ( $value instanceof ValueProxy )
		{
			return $value->ToInt( $provider );
		}

		if ( $value instanceof XPath2Item )
		{
			return Convert::ToInt( $value->getTypedValue(), $provider );
			// return $value->ToInt( $provider );
		}

		if ( is_numeric( $value ) )
		{
			if ( $value > PHP_INT_MAX ) return PHP_INT_MAX;
			if ( $value < PHP_INT_MIN ) return PHP_INT_MIN;
			return intval( $value + 0 );
		}

		if ( $value instanceof Integer || $value instanceof IntegerProxy || $value instanceof DecimalValue || $value instanceof DecimalProxy )
		{
			return $value->ToInt( $provider );
		}

		if ( $value instanceof \DateTime )
		{
			return $value->getTimestamp() + 0.0;
		}

		if ( $value instanceof DecimalValue )
		{
			return $value->ToInt( $provider );
		}

		return null;

	}