PHP Класс Neos\Flow\I18n\Parser\DatetimeParser

Показать файл Открыть проект

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

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

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

Метод Описание
injectDatesReader ( DatesReader $datesReader ) : void
parseDate ( string $dateToParse, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT, boolean $strictMode = true ) : mixed Parses date with format string for date defined in CLDR for particular locale.
parseDateAndTime ( string $dateAndTimeToParse, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT, boolean $strictMode = true ) : mixed Parses dateTime with format string for date and time defined in CLDR for particular locale.
parseDatetimeWithCustomPattern ( string $datetimeToParse, string $format, Locale $locale, boolean $strictMode = true ) : mixed Returns dateTime parsed by custom format (string provided in parameter).
parseTime ( string $timeToParse, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT, boolean $strictMode = true ) : mixed Parses time with format string for time defined in CLDR for particular locale.

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

Метод Описание
doParsingInLenientMode ( string $datetimeToParse, array $parsedFormat, array $localizedLiterals ) : array Parses date and / or time in lenient mode.
doParsingInStrictMode ( string $datetimeToParse, array $parsedFormat, array $localizedLiterals ) : array Parses date and / or time in strict mode.
doParsingWithParsedFormat ( string $datetimeToParse, array $parsedFormat, array $localizedLiterals, boolean $strictMode ) : mixed Parses date and / or time using parsed format, in strict or lenient mode.
extractAndCheckNumber ( string $datetimeToParse, boolean $isTwoDigits, integer $minValue, integer $maxValue ) : integer Extracts one or two-digit number from the beginning of the string.
extractNumberAndGetPosition ( string $datetimeToParse, integer &$position ) : string Extracts and returns first integer number encountered in provided string.

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

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

Algorithm assumptions: - ignore all literals - order of elements in parsed format is important - length of subformat is not strictly checked (eg. 'h' and 'hh') - number must be in range in order to be accepted (eg. 1-12 for month) - some format fallback substitutions can be done (eg. 'Jan' for 'January')
См. также: DatesReader
protected doParsingInLenientMode ( string $datetimeToParse, array $parsedFormat, array $localizedLiterals ) : array
$datetimeToParse string Date/time to be parsed
$parsedFormat array Format parsed by DatesReader
$localizedLiterals array Array of date / time literals from CLDR
Результат array Array of parsed date and / or time elements (can be array of NULLs if nothing was parsed)

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

Parses date and / or time in strict mode.
См. также: DatesReader
protected doParsingInStrictMode ( string $datetimeToParse, array $parsedFormat, array $localizedLiterals ) : array
$datetimeToParse string Date/time to be parsed
$parsedFormat array Format parsed by DatesReader
$localizedLiterals array Array of date / time literals from CLDR
Результат array Array of parsed date and / or time elements, FALSE on failure

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

Parses date and / or time using parsed format, in strict or lenient mode.
protected doParsingWithParsedFormat ( string $datetimeToParse, array $parsedFormat, array $localizedLiterals, boolean $strictMode ) : mixed
$datetimeToParse string Date/time to be parsed
$parsedFormat array Parsed format (from DatesReader)
$localizedLiterals array Array of date / time literals from CLDR
$strictMode boolean Work mode (strict when TRUE, lenient when FALSE)
Результат mixed Array of parsed date and / or time elements, FALSE on failure

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

If the number has certainly two digits, $isTwoDigits can be set to TRUE so no additional checking is done (this implies from some date/time formats, like 'hh'). Number is also checked for constraints: minimum and maximum value.
protected extractAndCheckNumber ( string $datetimeToParse, boolean $isTwoDigits, integer $minValue, integer $maxValue ) : integer
$datetimeToParse string Date/time to be parsed
$isTwoDigits boolean TRUE if number has surely two digits, FALSE if it has one or two digits
$minValue integer
$maxValue integer
Результат integer Parsed number

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

Searches for first digit and extracts all adjacent digits. Also returns position of first digit in string.
protected extractNumberAndGetPosition ( string $datetimeToParse, integer &$position ) : string
$datetimeToParse string String to search number in
$position integer Index of first digit in string
Результат string Extracted number

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

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

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

Parses date with format string for date defined in CLDR for particular locale.
public parseDate ( string $dateToParse, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT, boolean $strictMode = true ) : mixed
$dateToParse string date to be parsed
$locale Neos\Flow\I18n\Locale
$formatLength string One of: full, long, medium, short, or 'default' in order to use default length from CLDR
$strictMode boolean Work mode (strict when TRUE, lenient when FALSE)
Результат mixed Array of parsed date elements, FALSE on failure

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

Parses dateTime with format string for date and time defined in CLDR for particular locale.
public parseDateAndTime ( string $dateAndTimeToParse, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT, boolean $strictMode = true ) : mixed
$dateAndTimeToParse string Date and time to be parsed
$locale Neos\Flow\I18n\Locale
$formatLength string One of: full, long, medium, short, or 'default' in order to use default length from CLDR
$strictMode boolean Work mode (strict when TRUE, lenient when FALSE)
Результат mixed Array of parsed date and time elements, FALSE on failure

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

Format must obey syntax defined in CLDR specification, excluding unimplemented features (see documentation for DatesReader class). Format is remembered in cache and won't be parsed again for some time.
См. также: DatesReader
public parseDatetimeWithCustomPattern ( string $datetimeToParse, string $format, Locale $locale, boolean $strictMode = true ) : mixed
$datetimeToParse string Date/time to be parsed
$format string Format string
$locale Neos\Flow\I18n\Locale A locale used for finding literals array
$strictMode boolean Work mode (strict when TRUE, lenient when FALSE)
Результат mixed Array of parsed date / time elements, FALSE on failure

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

Parses time with format string for time defined in CLDR for particular locale.
public parseTime ( string $timeToParse, Locale $locale, string $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT, boolean $strictMode = true ) : mixed
$timeToParse string Time to be parsed
$locale Neos\Flow\I18n\Locale
$formatLength string One of: full, long, medium, short, or 'default' in order to use default length from CLDR
$strictMode boolean Work mode (strict when TRUE, lenient when FALSE)
Результат mixed Array of parsed time elements, FALSE on failure

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

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

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