W3cubDocs

/Symfony 4.1

Hour2401Transformer

class Hour2401Transformer extends HourTransformer

Parser and formatter for 24 hour format (1-24).

Methods

string format(DateTime $dateTime, int $length)

Format a value using a configured DateTime as date/time source.

string getReverseMatchingRegExp(int $length)

Returns a reverse matching regular expression of a string generated by format().

array extractDateOptions(string $matched, int $length)

Extract date options from a matched value returned by the processing of the reverse matching regular expression.

string padLeft(string $value, int $length)

Pad a string with zeros to the left.

from Transformer
int normalizeHour(int $hour, string $marker = null)

Returns a normalized hour value suitable for the hour transformer type.

Details

string format(DateTime $dateTime, int $length)

Format a value using a configured DateTime as date/time source.

Parameters

DateTime $dateTime A DateTime object to be used to generate the formatted value
int $length The formatted value string length

Return Value

string The formatted value

string getReverseMatchingRegExp(int $length)

Returns a reverse matching regular expression of a string generated by format().

Parameters

int $length The length of the value to be reverse matched

Return Value

string The reverse matching regular expression

array extractDateOptions(string $matched, int $length)

Extract date options from a matched value returned by the processing of the reverse matching regular expression.

Parameters

string $matched The matched value
int $length The length of the Transformer pattern string

Return Value

array An associative array

protected string padLeft(string $value, int $length)

Pad a string with zeros to the left.

Parameters

string $value The string to be padded
int $length The length to pad

Return Value

string The padded string

int normalizeHour(int $hour, string $marker = null)

Returns a normalized hour value suitable for the hour transformer type.

Parameters

int $hour The hour value
string $marker An optional AM/PM marker

Return Value

int The normalized hour value