Returns the name of the given field value.

It will be used to generate content name and url alias if current field is designated
to be used in the content name/urlAlias pattern.

@param \eZ\Publish\Core\FieldType\Time\Value $value

@return string
339122
public function getName(SPIValue $value)
    {
        if ($this->isEmptyValue($value)) {
            return '';
        }

        $dateTime = new DateTime("@{$value->time}");

        return $dateTime->format('g:i:s a');
    }
901516
public function formatTimeago($value)
    {
        if ($value instanceof DateTime) {
            $value = date_timestamp_get($value);

        } else if (!is_numeric($value) && is_string($value)) {
            $value = strtotime($value);
        }

        return $this->inWords((time() - $value));
    }
1338530
public static function getName($value)
    {
        $enumerables = self::getCache();
        $result = array_search($value, $enumerables, true);
        
        if ($result === false) {
            throw EnumerableException::valueNotFound();
        }
        
        return $result;
    }
901659
private function formatTimestampForApi($value)
    {
        list ($dt, $nanos) = $this->parseTimeString($value);

        return [
            'seconds' => (int) $dt->format('U'),
            'nanos' => (int) $nanos
        ];
    }
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;
    }
244661
protected static function _getDateString($value)
    {
        $formatted = '';
        if (isset($value['year'], $value['month'], $value['day']) &&
            (is_numeric($value['year']) && is_numeric($value['month']) && is_numeric($value['day']))
        ) {
            $formatted .= sprintf('%d-%02d-%02d ', $value['year'], $value['month'], $value['day']);
        }

        if (isset($value['hour'])) {
            if (isset($value['meridian']) && (int)$value['hour'] === 12) {
                $value['hour'] = 0;
            }
            if (isset($value['meridian'])) {
                $value['hour'] = strtolower($value['meridian']) === 'am' ? $value['hour'] : $value['hour'] + 12;
            }
            $value += ['minute' => 0, 'second' => 0];
            if (is_numeric($value['hour']) && is_numeric($value['minute']) && is_numeric($value['second'])) {
                $formatted .= sprintf('%02d:%02d:%02d', $value['hour'], $value['minute'], $value['second']);
            }
        }

        return trim($formatted);
    }
475872
public function getFieldName(SPIValue $value, FieldDefinition $fieldDefinition, $languageCode)
    {
        return $this->fieldType->getName($value);
    }
113676
protected function nicetime($value) {
        if (!$value) {
            return '';
        } else if ($value > mktime(0, 0, 0, date('m'), date('d'), date('Y'))) {
            return 'Today ' . date('g:i a', $value);
        } else if ($value > mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))) {
            return 'Yesterday ' . date('g:i a', $value);
        } else {
            return date('jS F Y, g:i a', $value);
        }
    }
1211506
static public function toUnixtime($value=null)
    {
        return (empty($value)) ? time() : (is_numeric($value) ? $value : strtotime($value));
    }
962468
protected function databaseValue($value)
    {
        if (!$value instanceof \DateTime) {
            throw ODMException::conversionFailedInvalidType($value, Type::TIMESTAMP, ['null', 'DateTime']);
        }

        return (string)$value->getTimestamp();
    }
743180
public function format($format, $value)
    {
        switch ($format) {
            case 'date-time':
                return $this->formatDateTime($value);
            case 'date-time-http':
                return $this->formatDateTimeHttp($value);
            case 'date':
                return $this->formatDate($value);
            case 'time':
                return $this->formatTime($value);
            case 'timestamp':
                return $this->formatTimestamp($value);
            case 'boolean-string':
                return $this->formatBooleanAsString($value);
            default:
                return $value;
        }
    }
1181907
private function serializeField($value)
    {
        if (is_string($value)) {
            // @todo Could be decimal (D) or byte array (x)
            // @see https://github.com/recoilphp/amqp/issues/25
            return 'S' . $this->serializeLongString($value);
        }
        if (is_int($value)) {
            // @todo Could be timestamp (T)
            // @see https://github.com/recoilphp/amqp/issues/25
            if ($value >= 0) {
                if ($value < 0x80) {
                    return 'b' . $this->serializeSignedInt8($value);
                }
                if ($value < 0x8000) {
                    return 's' . $this->serializeSignedInt16($value);
                }
                if ($value < 0x80000000) {
                    return 'I' . $this->serializeSignedInt32($value);
                }
            } else {
                if ($value >= -0x80) {
                    return 'b' . $this->serializeSignedInt8($value);
                }
                if ($value >= -0x8000) {
                    return 's' . $this->serializeSignedInt16($value);
                }
                if ($value >= -0x80000000) {
                    return 'I' . $this->serializeSignedInt32($value);
                }
            }

            return 'l' . $this->serializeSignedInt64($value);
        }
        if (true === $value) {
            return "t\x01";
        }
        if (false === $value) {
            return "t\x00";
        }
        if (null === $value) {
            return 'V';
        }
        if (is_float($value)) {
            return 'd' . $this->serializeDouble($value);
        }
        if (is_array($value)) {
            return $this->serializeArrayOrTable($value);
        }
        throw new InvalidArgumentException(
            'Could not serialize value (' . chr($value) . ').'
        );
    }
685598
public function getName(SPIValue $value)
    {
        $result = null;
        if ($section = $value->xml->documentElement->firstChild) {
            $textDom = $section->firstChild;

            if ($textDom && $textDom->hasChildNodes()) {
                $result = $textDom->firstChild->textContent;
            } elseif ($textDom) {
                $result = $textDom->textContent;
            }
        }

        if ($result === null) {
            $result = $value->xml->documentElement->textContent;
        }

        return trim(preg_replace(array('/\n/', '/\s\s+/'), ' ', $result));
    }
570158
public function stringify($value): string
    {
        if ($value instanceof \DateTimeInterface) {
            return $value->format('Y-m-d');
        }

        if (is_array($value)) {
            return self::ARRAY_VALUE;
        }

        if (is_object($value) && !method_exists($value, '__tostring')) {
            return self::OBJECT_VALUE;
        }

        return (string)$value;
    }
1092564
private function getField($position, $value)
    {
        switch ($position) {
            case 0:
                return new MinuteField($value);
            case 1:
                return new HourField($value);
            case 2:
                return new DayOfMonthField($value);
            case 3:
                return new MonthField($value);
            case 4:
                return new DayOfWeekField($value);
            case 5:
                return new YearField($value);
            default:
                throw new \InvalidArgumentException(sprintf('%s is not a valid CRON expression position.', $position));
        }
    }
391452
protected static function parseValue($value)
    {
        if ($value instanceof \DateTime) {
            return 'new \\DateTime(' . \var_export($value->format('c'), true) . ')';
        }

        if (!\is_string($value)) {
            return \var_export($value, true);
        }

        if (\preg_match('/%([a-zA-Z0-9_:\\\]+)(?::(.*))?%/', $value, $matches)) {
            $function = $matches[1];

            if (!\function_exists($function)) {
                return $value;
            }

            if (!isset($matches[2])) {
                return $function . '()';
            }

            $args = \explode(',', $matches[2]);
            foreach ($args as &$a) {
                $a = static::parseConstant(\trim($a));
            }

            return $function . '(' . \implode(', ', $args) . ')';
        }

        return static::parseConstant($value);
    }
283766
private function stringifyValue($value)
    {
        switch (true) {
            case $value === null:
                $value = 'NULL';
                break;
            case ($value instanceof \DateTime):
                $value = $value->format(DATE_RFC822);
                break;
            case ($value instanceof StringableInterface):
                $value = $value->toString();
                break;
            case ($value instanceof ArrayableInterface):
                $value = sprintf('Arrayable::%s (%s)', (new \ReflectionObject($value))->getShortName(),
                    $this->stringifyValue($value->toArray()));
                break;
            case is_scalar($value):
            case method_exists($value, '__toString'):
                $value = (string) $value;
                break;
            case is_object($value):
                $value = sprintf('Object (%s)', get_class($value));
                break;
            case is_array($value):
                $value = sprintf('Array (%s)', implode(', ', array_map([$this, 'stringifyValue'], $value)));
                break;
        }
        
        return $value;
    }