Get base string from date column.
@param Array $data
@param Array $baseField Base field config
@return String
180576
protected function _getBaseStringFromDate(array $data, array $baseField) {
        $col = $baseField['column'];
        $format = $baseField['format'] ?: 'd-m-Y';
        if (!array_key_exists($col, $data)) {
            return '';
        }
        return date($format, strtotime($data[$col]));
    }
596877
public function format_template($field)
    {
        if (!($t = $this->columns[$field]['template'])) {
            throw new BaseException('use setTemplate() for field '.$field);
        }

        $this->current_row_html[$field] = $t
            ->trySet('id', $this->current_id)
            ->set($this->current_row)
            ->trySet('_value_', $this->current_row[$field])
            ->render();
    }
613870
protected function encode(array $data)
    {

        foreach ($data as $key => $value) {
            if (is_string($value)) {
                $data[$key] = base64_encode($value);
            }
        }

        return $data;
    }
192871
protected function buildDateTimebyString($stringDate, $base = null)
    {
        if (is_null($base)) {
            $base = time();
        }

        try {
            $base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base);
            $dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base);
            $date = new \DateTime('@' . $dateTimestamp);
            $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
        } catch (\Exception $exception) {
            throw new Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579);
        }
    }
271467
static private function formatStringValue($baseType, $stringValue){

        switch(strtolower($baseType)){
            case 'string':
            case 'duration':
                return $stringValue;
            case 'identifier':
                return self::trimIdentifier($stringValue);
            case 'integer':
                return intval($stringValue);
            case 'float':
                return floatval($stringValue);
            case 'boolean':
                return (trim($stringValue) === 'true' || $stringValue === true) ? true : false;
            case 'pair':
            case 'directedpair':
                $pair = explode(' ', trim($stringValue));
                if(count($pair) != 2){
                    throw new \common_Exception('invalid pair string');
                }
                return [self::trimIdentifier($pair[0]), self::trimIdentifier($pair[1])];
            case 'point':
                $pair = explode(' ', trim($stringValue));
                if(count($pair) != 2){
                    throw new \common_Exception('invalid point string');
                }
                return [intval($pair[0]), intval($pair[1])];
            default:
                throw new \common_exception_NotImplemented('unknown basetype');
        }
    }
1060506
protected function getRowSql($data, $columnFields) {
        $args = [];
        foreach ($data as $key => $item) {
            if (is_null($item)) {
                $args[] = 'NULL';
                continue;
            }
            if (array_key_exists($key, $columnFields) && $columnFields[$key]) {
                $args[] = $item;
                continue;
            }
            $args[] = sprintf('\'%s\'',
                str_replace(
                    ["\r\n", "\r", "\n", '\\\'', '\''],
                    ["\n", '\r\n', '\r\n', '\'', '\\\''], $item));
        }
        return implode(',',$args);
    }
8916
protected function _getBaseString($baseField, $data) {
        $type = $baseField['type'];
        $method = '_getBaseStringFrom' . ucfirst($type);
        return $this->{$method}($data, $baseField);
    }
1164711
public static function decode($data)
    {
        if (!is_string($data)) {
            throw new InvalidArgumentException('data must be string');
        }
        if (1 === strlen($data) % 4) {
            throw new InvalidArgumentException('invalid base64 string length');
        }
        $result = base64_decode($data, true);
        if (false === $result) {
            throw new InvalidArgumentException('invalid base64 string');
        }

        return $result;
    }
1171230
protected function getFieldNameFromData($fieldName, $data, $default = null)
    {
        /*
         * Array field name, eg: field[key][key2][key3]
         */
        $keyParts = HtmlHelper::nameToArray($fieldName);
        $lastField = end($keyParts);
        $result = $data;

        /*
         * Loop the field key parts and build a value.
         * To support relations only the last field should return the
         * relation value, all others will look up the relation object as normal.
         */
        foreach ($keyParts as $key) {

            if ($result instanceof Model && $result->hasRelation($key)) {
                if ($key == $lastField) {
                    $result = $result->getRelationValue($key) ?: $default;
                }
                else {
                    $result = $result->{$key};
                }
            }
            elseif (is_array($result)) {
                if (!array_key_exists($key, $result)) {
                    return $default;
                }
                $result = $result[$key];
            }
            else {
                if (!isset($result->{$key})) {
                    return $default;
                }
                $result = $result->{$key};
            }

        }

        return $result;
    }
693471
public function serializeBase64(SerializationVisitorInterface $visitor, string $data, array $type)
    {
        return $visitor->visitString(base64_encode($data), $type);
    }
1324136
protected function setCustomFields($base, $data, array $model_registry = array())
    {
        if (count($this->customfieldgroups) > 0) {
        } else {
            return $base;
        }

        foreach ($this->customfieldgroups as $group) {
            $group_data   = $this->processQueryFields(json_decode($data->$group), $model_registry [$group]);
            $base->$group = $this->sortObject($group_data);
        }

        return $base;
    }
1170042
private String zGetStandardTextFieldDateString(LocalDate date) {
        if (settings == null) {
            return "";
        }
        String standardDateString = "";
        if (date == null) {
            return standardDateString;
        }
        if (date.getEra() == IsoEra.CE) {
            standardDateString = date.format(settings.getFormatForDatesCommonEra());
        } else {
            standardDateString = date.format(settings.getFormatForDatesBeforeCommonEra());
        }
        return standardDateString;
    }
939675
public static function getUtcDateTime( BaseDateTime $date )
    {
        $newDate = new BaseDateTime( );
        $newDate->setTimestamp( $date->getTimestamp() );
        $newDate->setTimezone( new DateTimeZone( 'UTC' ) );
        
        return $newDate;
    }
131823
public static function base64( $data, $encode = 0 ) {
		$out = $encode ? base64_encode( $data ) : base64_decode( $data );

		return $out;
	}
1283409
protected function processQueryFields($data, array $fields = array())
    {
        $base = new stdClass();

        if (count($fields) === 0) {
            return $base;
        }

        foreach ($fields as $key => $field) {

            $this->verifyFieldDefined($key, $field);

            if (in_array($field['name'], $this->customfieldgroups)
                || $field['type'] === 'customfield'
            ) {
            } else {
                $base->$field['name'] = $this->processQueryField($data, $field);
            }
        }

        return $this->sortObject($base);
    }
741830
protected static function bcDec2Base($number, $base, $baseChar)
    {
        $result    = '';
        $numberLen = strlen($number);
        // Now loop through each digit in the number
        for ($i = $numberLen - 1; $i >= 0; --$i) {
            $char = $number[$i]; // extract the last char from the number
            $ord  = strpos($baseChar, $char); // get the decimal value
            if ($ord === false || $ord > $base) {
                throw new \InvalidArgumentException('Argument number is invalid');
            }

            // Now convert the value+position to decimal
            $result = bcadd($result, bcmul($ord, bcpow($base, ($numberLen - $i - 1))));
        }

        return $result ? $result : '0';
    }
36384
public static function queryByBaseId( $baseId, $config = [] ) {

		$type	= isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
		$status	= isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;

		return self::find()->where( [ 'baseId' => $baseId, 'type' => $type, 'status' => $status ] );
	}