Convert dates from SQL format to ISO 8601

@param   mixed  $object  Convert date keys
@return  mixed  Converted object
354501
private function convertDateKeysInObjects($object)
	{
		// only hanlde objects
		if (!is_object($object))
		{
			return $object;
		}

		// spin over each key replacing the date with new format
		foreach (array_keys(get_object_vars($object)) as $key)
		{
			if (in_array($key, $this->dateKeys))
			{
				$object->$key = with(new Date($object->$key))->format('Y-m-d\TH:i:s\Z');
			}
		}

		// return object
		return $object;
	}
244683
public static function parse($object){
		
		$num = \preg_replace('/[^\.\d]/', '', \strval($object));
		
		list($m, $d) = \explode('.', $num, 2);
		
		$mLen = \strlen($m);
		$dLen = \strlen($d);
				
		if(!Number::between($mLen, MySQL::getConstant('DECIMAL_M_MIN'),
				MySQL::getConstant('DECIMAL_M_MAX'))){
			return null;
		}
		
		if(!Number::between($dLen, MySQL::getConstant('DECIMAL_D_MIN'),
				MySQL::getConstant('DECIMAL_D_MAX'))){
			return null;
		}
		
		if($dLen > $mLen){
			return null;
		}
		
		return new static($mLen, $dLen);
		
	}
1250672
protected function createSObject($object, $objectType)
    {
        $sObject = new \stdClass();

        foreach (get_object_vars($object) as $field => $value) {
            $type = $this->soapClient->getSoapElementType($objectType, $field);
            if ($field != 'Id' && !$type) {
                continue;
            }

            if ($value === null) {
                $sObject->fieldsToNull[] = $field;
                continue;
            }

            // As PHP \DateTime to SOAP dateTime conversion is not done
            // automatically with the SOAP typemap for sObjects, we do it here.
            switch ($type) {
                case 'date':
                    if ($value instanceof \DateTime) {
                        $value  = $value->format('Y-m-d');
                    }
                    break;
                case 'dateTime':
                    if ($value instanceof \DateTime) {
                        $value  = $value->format('Y-m-d\TH:i:sP');
                    }
                    break;
                case 'base64Binary':
                    $value = base64_encode($value);
                    break;
            }

            $sObject->$field = $value;
        }

        return $sObject;
    }
511339
protected function hydrateObjectForm($object)
    {
        $data = array(
            "id" => $object->getId(),
            "visible" => (bool) $object->getVisible(),
            "code" => $object->getCode(),
            "title" => $object->getTitle(),
            "type" => $object->getType(),
            "entity" => $object->getEntity(),
            "serialized_columns" => $object->getSerializedColumns(),
            "serialized_condition" => $object->getSerializedCondition(),
            "index_engine_driver_configuration_id" => $object->getIndexEngineDriverConfigurationId(),
        );

        return $this->getUpdateForm($data);
    }
864829
private function convert(Array $object): Array {
    $parse = Array();
    foreach ($object as $key => $value) {
      if ($value instanceof stdClass) {
        $parse[$key] = $this->convert((Array) $value);
      } else {
        $parse[$key] = $value;
      }
    }
    return $parse;
  }
958837
public function normalize($object, $format = null, array $context = [])
    {
        if (!$object instanceof \DateTimeInterface) {
            throw new InvalidArgumentException('The object must implement the "\DateTimeInterface".');
        }

        $dateTimeFormat = $context[self::FORMAT_KEY] ?? $this->defaultContext[self::FORMAT_KEY];
        $timezone = $this->getTimezone($context);

        if (null !== $timezone) {
            $object = clone $object;
            $object = $object->setTimezone($timezone);
        }

        return $object->format($dateTimeFormat);
    }
975855
protected function hydrateObjectForm($object)
    {
        $data = array(
            "id" => $object->getId(),
            "title" => $object->getTitle(),
            "address1" => $object->getAddress1(),
            "address2" => $object->getAddress2(),
            "address3" => $object->getAddress3(),
            "zipcode" => $object->getZipcode(),
            "city" => $object->getCity(),
            "country_id" => $object->getCountryId(),
            "description" => $object->getDescription(),
            "latitude" => $object->getLatitude(),
            "longitude" => $object->getLongitude(),
        );

        return $this->getUpdateForm($data);
    }
1022166
public function transform($object)
    {
        if (null === $object) {
            return '';
        }

        return current(array_values($this->om->getClassMetadata($this->entityName)->getIdentifierValues($object)));
    }
927220
protected function convertDate($date) : string
    {
        if (is_a($date, 'DateTime')) {
            return (string) $date->format(DateTime::ISO8601);
        }

        return $date;
    }
154613
private function getCachedDataByObject($object)
    {
        return $this->getCachedDataByReference(
            $this->mm->getMetadataForObject($object)->getReferenceForObject($object)
        );
    }
395556
public static function insert($object)
    {
        $db = new DatabaseManager();
        $connection = $db->getDbh();

        $objectAsArrayForSqlInsert = DatatbaseUtility::objectToArrayLessId($object);
        $fields = array_keys($objectAsArrayForSqlInsert);
        $insertFieldList = DatatbaseUtility::fieldListToInsertString($fields);
        $valuesFieldList = DatatbaseUtility::fieldListToValuesString($fields);

        $statement = $connection->prepare('INSERT into '. static::getTableName()  . ' ' . $insertFieldList . $valuesFieldList);
        $statement->execute($objectAsArrayForSqlInsert);

        $queryWasSuccessful = ($statement->rowCount() > 0);
        if ($queryWasSuccessful) {
            return $connection->lastInsertId();
        } else {
            return -1;
        }
    }
705573
public function getDate(bool $asObject = false)
    {
        if (true === $asObject) {
            return \DateTimeImmutable::createFromFormat('!Ymd', $this->date, new \DateTimeZone('UTC'));
        }

        return $this->date;
    }
302110
protected function objectToFields($dataObject) {
		$ret = array();

		$fields = Config::inst()->get($dataObject->ClassName, 'db');
		$fields['Created'] = 'SS_Datetime';
		$fields['LastEdited'] = 'SS_Datetime';

		$ret['ClassName'] = array('Type' => 'Varchar', 'Value' => $dataObject->class);
		$ret['SS_ID'] = array('Type' => 'Int', 'Value' => $dataObject->ID);

		foreach ($fields as $name => $type) {
			if (preg_match('/^(\w+)\(/', $type, $match)) {
				$type = $match[1];
			}

			// Just index everything; the query can figure out what to exclude... !
			$value = $dataObject->$name;

			if ($type == 'MultiValueField' && $value instanceof MultiValueField) {
				$value = $value->getValues();
			}

			$ret[$name] = array('Type' => $type, 'Value' => $value);
		}

		$rels = Config::inst()->get($dataObject->ClassName, 'has_one');

		if($rels) foreach(array_keys($rels) as $rel) {
			$ret["{$rel}ID"] = array(
				'Type'  => 'ForeignKey',
				'Value' => $dataObject->{$rel . "ID"}
			);
		}
		
		if ($dataObject->hasMethod('additionalSolrValues')) {
			$extras = $dataObject->invokeWithExtensions('additionalSolrValues');
			if ($extras && is_array($extras)) {
				foreach ($extras as $add) {
					foreach ($add as $k => $v) {
						$ret[$k] = array(
							'Type'		=> $this->mapper->mapValueToType($k, $v),
							'Value'		=> $v,
						);
					}
				}
			}
		}

		return $ret;
	}
73461
static private function objToArray(&$object)
    {
        if (is_object($object) && method_exists($object, '__trace')){
            $arr = $object->__trace();
            if (!is_array($arr)) return $arr;
        }else{
            $arr = (array)$object;
        }
        $result = [];
        while (list ($key, $value) = each($arr)){
            $keys = explode("\0", $key);
            $clear_key = $keys[sizeof($keys) - 1];
            $result[$clear_key] = &$arr[$key];
        }
        return $result;
    }
366106
public static function toSimpleArray( $object )
    {
        if ( is_object( $object ) )
        {
            $object = (array)$object;
        }

        if ( !is_array( $object ) )
        {
            return $object;
        }

        $_result = array();

        foreach ( $object as $_key => $_value )
        {
            $_result[preg_replace( "/^\\0(.*)\\0/", "", $_key )] = self::toSimpleArray( $_value );
        }

        return $_result;
    }
165985
def _datetime_to_iso8601(self, query_dict):
        """"""
        return {
            k: v if not isinstance(v, datetime.datetime) else v.isoformat()
            for k, v in list(query_dict.items())
        }
1110283
public function extract($object)
    {
        $data = parent::extract($object);

        foreach ($this->getFreeValuesKeys() as $key) {
            $data[$key] = $object->get($key);
        }

        return $data;
    }