PHP Класс Neos\Flow\I18n\Formatter\DatetimeFormatter

This is not full implementation of features from CLDR. These are missing: - support for other calendars than Gregorian - rules for displaying timezone names are simplified - some less frequently used format characters are not supported
Наследование: implements Neos\Flow\I18n\Formatter\FormatterInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$datesReader Neos\Flow\I18n\Cldr\Reader\DatesReader

Открытые методы

Метод Описание
format ( mixed $value, Locale $locale, array $styleProperties = [] ) : string Formats provided value using optional style properties
formatDate ( DateTimeInterface $date, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT ) : string Formats date with format string for date defined in CLDR for particular locale.
formatDateTime ( DateTimeInterface $dateTime, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT ) : string Formats dateTime with format string for date and time defined in CLDR for particular locale.
formatDateTimeWithCustomPattern ( DateTimeInterface $dateTime, string $format, Locale $locale ) : string Returns dateTime formatted by custom format, string provided in parameter.
formatTime ( DateTimeInterface $time, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT ) : string Formats time with format string for time defined in CLDR for particular locale.
injectDatesReader ( DatesReader $datesReader ) : void

Защищенные методы

Метод Описание
doFormattingForSubpattern ( DateTimeInterface $dateTime, string $subformat, array $localizedLiterals ) : string Formats date or time element according to the subpattern provided.
doFormattingWithParsedFormat ( DateTimeInterface $dateTime, array $parsedFormat, array $localizedLiterals ) : string Formats provided dateTime object.
padString ( string $string, integer $formatLength ) : string Pads given string to the specified length with zeros.

Описание методов

doFormattingForSubpattern() защищенный Метод

Returns a string with formatted one "part" of DateTime object (seconds, day, month etc). Not all pattern symbols defined in CLDR are supported; some of the rules are simplified. Please see the documentation for DatesReader for details. Cases in the code are ordered in such way that probably mostly used are on the top (but they are also grouped by similarity).
См. также: Neos\Flow\I18n\Cldr\Reader\DatesReader
protected doFormattingForSubpattern ( DateTimeInterface $dateTime, string $subformat, array $localizedLiterals ) : string
$dateTime DateTimeInterface PHP object representing particular point in time
$subformat string One element of format string (e.g., 'yyyy', 'mm', etc)
$localizedLiterals array Array of date / time literals from CLDR
Результат string Formatted part of date / time

doFormattingWithParsedFormat() защищенный Метод

Format rules defined in $parsedFormat array are used. Localizable literals are replaced with elements from $localizedLiterals array.
protected doFormattingWithParsedFormat ( DateTimeInterface $dateTime, array $parsedFormat, array $localizedLiterals ) : string
$dateTime DateTimeInterface PHP object representing particular point in time
$parsedFormat array An array describing format (as in $parsedFormats property)
$localizedLiterals array An array with literals to use (as in $localizedLiterals property)
Результат string Formatted date / time

format() публичный Метод

Formats provided value using optional style properties
public format ( mixed $value, Locale $locale, array $styleProperties = [] ) : string
$value mixed Formatter-specific variable to format (can be integer, \DateTime, etc)
$locale Neos\Flow\I18n\Locale Locale to use
$styleProperties array Integer-indexed array of formatter-specific style properties (can be empty)
Результат string String representation of $value provided, or (string)$value

formatDate() публичный Метод

Formats date with format string for date defined in CLDR for particular locale.
public formatDate ( DateTimeInterface $date, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT ) : string
$date DateTimeInterface PHP object representing particular point in time
$locale Neos\Flow\I18n\Locale
$formatLength string One of DatesReader FORMAT_LENGTH constants
Результат string Formatted date

formatDateTime() публичный Метод

First date and time are formatted separately, and then dateTime format from CLDR is used to place date and time in correct order.
public formatDateTime ( DateTimeInterface $dateTime, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT ) : string
$dateTime DateTimeInterface PHP object representing particular point in time
$locale Neos\Flow\I18n\Locale
$formatLength string One of DatesReader FORMAT_LENGTH constants
Результат string Formatted date and time

formatDateTimeWithCustomPattern() публичный Метод

Format must obey syntax defined in CLDR specification, excluding unimplemented features (see documentation for DatesReader class). Format is remembered in this classes cache and won't be parsed again for some time.
См. также: Neos\Flow\I18n\Cldr\Reader\DatesReader
public formatDateTimeWithCustomPattern ( DateTimeInterface $dateTime, string $format, Locale $locale ) : string
$dateTime DateTimeInterface PHP object representing particular point in time
$format string Format string
$locale Neos\Flow\I18n\Locale A locale used for finding literals array
Результат string Formatted date / time. Unimplemented subformats in format string will be silently ignored

formatTime() публичный Метод

Formats time with format string for time defined in CLDR for particular locale.
public formatTime ( DateTimeInterface $time, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT ) : string
$time DateTimeInterface PHP object representing particular point in time
$locale Neos\Flow\I18n\Locale
$formatLength string One of DatesReader FORMAT_LENGTH constants
Результат string Formatted time

injectDatesReader() публичный Метод

public injectDatesReader ( DatesReader $datesReader ) : void
$datesReader Neos\Flow\I18n\Cldr\Reader\DatesReader
Результат void

padString() защищенный Метод

Pads given string to the specified length with zeros.
protected padString ( string $string, integer $formatLength ) : string
$string string
$formatLength integer
Результат string Padded string (can be unchanged if $formatLength is lower than length of string)

Описание свойств

$datesReader защищенное свойство

protected DatesReader,Neos\Flow\I18n\Cldr\Reader $datesReader
Результат Neos\Flow\I18n\Cldr\Reader\DatesReader