Duration
extends DateTimeWizard
in package
Table of Contents
Constants
- DAYS_DURATION = 'd'
- DURATION_DEFAULT = [self::HOURS_DURATION, self::MINUTES_LONG, self::SECONDS_LONG]
- HOURS_DURATION = '[h]'
- Hours as a duration (can exceed 24), e.g. 29.
- HOURS_LONG = 'hh'
- Hours with a leading zero, e.g. 09.
- HOURS_SHORT = 'h'
- Hours without a leading zero, e.g. 9.
- MINUTES_DURATION = '[m]'
- Minutes as a duration (can exceed 60), e.g. 109.
- MINUTES_LONG = 'mm'
- Minutes with a leading zero, e.g. 05.
- MINUTES_SHORT = 'm'
- Minutes without a leading zero, e.g. 5.
- SECONDS_DURATION = '[s]'
- Seconds as a duration (can exceed 60), e.g. 129.
- SECONDS_LONG = 'ss'
- Seconds with a leading zero, e.g. 02.
- SECONDS_SHORT = 's'
- Seconds without a leading zero, e.g. 2.
- SEPARATOR_COLON = ':'
- SEPARATOR_SPACE = ' '
- SEPARATOR_SPACE_NONBREAKING = " "
- DURATION_BLOCKS = [self::DAYS_DURATION, self::HOURS_DURATION, self::HOURS_LONG, self::HOURS_SHORT, self::MINUTES_DURATION, self::MINUTES_LONG, self::MINUTES_SHORT, self::SECONDS_DURATION, self::SECONDS_LONG, self::SECONDS_SHORT]
- DURATION_DEFAULTS = [self::HOURS_LONG => self::HOURS_DURATION, self::HOURS_SHORT => self::HOURS_DURATION, self::MINUTES_LONG => self::MINUTES_DURATION, self::MINUTES_SHORT => self::MINUTES_DURATION, self::SECONDS_LONG => self::SECONDS_DURATION, self::SECONDS_SHORT => self::SECONDS_DURATION]
- DURATION_MASKS = [self::DAYS_DURATION => self::DAYS_DURATION, self::HOURS_DURATION => self::HOURS_SHORT, self::MINUTES_DURATION => self::MINUTES_LONG, self::SECONDS_DURATION => self::SECONDS_LONG]
- NO_ESCAPING_NEEDED = "\$+-/():!^&'~{}<>= "
Properties
- $durationIsSet : bool
- $formatBlocks : array<string|int, string>
- $separators : array<string|int, string>
Methods
- __construct() : mixed
- __toString() : string
- format() : string
- escapeSingleCharacter() : string
- intersperse() : string
- padSeparatorArray() : array<string|int, mixed>
- wrapLiteral() : string
- mapFormatBlocks() : string
Constants
DAYS_DURATION
public
mixed
DAYS_DURATION
= 'd'
DURATION_DEFAULT
public
mixed
DURATION_DEFAULT
= [self::HOURS_DURATION, self::MINUTES_LONG, self::SECONDS_LONG]
HOURS_DURATION
Hours as a duration (can exceed 24), e.g. 29.
public
mixed
HOURS_DURATION
= '[h]'
HOURS_LONG
Hours with a leading zero, e.g. 09.
public
mixed
HOURS_LONG
= 'hh'
HOURS_SHORT
Hours without a leading zero, e.g. 9.
public
mixed
HOURS_SHORT
= 'h'
MINUTES_DURATION
Minutes as a duration (can exceed 60), e.g. 109.
public
mixed
MINUTES_DURATION
= '[m]'
MINUTES_LONG
Minutes with a leading zero, e.g. 05.
public
mixed
MINUTES_LONG
= 'mm'
MINUTES_SHORT
Minutes without a leading zero, e.g. 5.
public
mixed
MINUTES_SHORT
= 'm'
SECONDS_DURATION
Seconds as a duration (can exceed 60), e.g. 129.
public
mixed
SECONDS_DURATION
= '[s]'
SECONDS_LONG
Seconds with a leading zero, e.g. 02.
public
mixed
SECONDS_LONG
= 'ss'
SECONDS_SHORT
Seconds without a leading zero, e.g. 2.
public
mixed
SECONDS_SHORT
= 's'
SEPARATOR_COLON
public
mixed
SEPARATOR_COLON
= ':'
SEPARATOR_SPACE
public
mixed
SEPARATOR_SPACE
= ' '
SEPARATOR_SPACE_NONBREAKING
public
mixed
SEPARATOR_SPACE_NONBREAKING
= " "
DURATION_BLOCKS
protected
mixed
DURATION_BLOCKS
= [self::DAYS_DURATION, self::HOURS_DURATION, self::HOURS_LONG, self::HOURS_SHORT, self::MINUTES_DURATION, self::MINUTES_LONG, self::MINUTES_SHORT, self::SECONDS_DURATION, self::SECONDS_LONG, self::SECONDS_SHORT]
DURATION_DEFAULTS
protected
mixed
DURATION_DEFAULTS
= [self::HOURS_LONG => self::HOURS_DURATION, self::HOURS_SHORT => self::HOURS_DURATION, self::MINUTES_LONG => self::MINUTES_DURATION, self::MINUTES_SHORT => self::MINUTES_DURATION, self::SECONDS_LONG => self::SECONDS_DURATION, self::SECONDS_SHORT => self::SECONDS_DURATION]
DURATION_MASKS
protected
mixed
DURATION_MASKS
= [self::DAYS_DURATION => self::DAYS_DURATION, self::HOURS_DURATION => self::HOURS_SHORT, self::MINUTES_DURATION => self::MINUTES_LONG, self::SECONDS_DURATION => self::SECONDS_LONG]
NO_ESCAPING_NEEDED
protected
mixed
NO_ESCAPING_NEEDED
= "\$+-/():!^&'~{}<>= "
Properties
$durationIsSet
protected
bool
$durationIsSet
= false
$formatBlocks
protected
array<string|int, string>
$formatBlocks
$separators
protected
array<string|int, string>
$separators
Methods
__construct()
public
__construct([null|string|array<string|int, string> $separators = self::SEPARATOR_COLON ], string ...$formatBlocks) : mixed
Parameters
- $separators : null|string|array<string|int, string> = self::SEPARATOR_COLON
-
If you want to use the same separator for all format blocks, then it can be passed as a string literal; if you wish to use different separators, then they should be passed as an array. If you want to use only a single format block, then pass a null as the separator argument
- $formatBlocks : string
__toString()
public
__toString() : string
Return values
stringformat()
public
format() : string
Return values
stringescapeSingleCharacter()
protected
escapeSingleCharacter(string $value) : string
Parameters
- $value : string
Return values
stringintersperse()
protected
intersperse(string $formatBlock, string|null $separator) : string
Parameters
- $formatBlock : string
- $separator : string|null
Return values
stringpadSeparatorArray()
protected
padSeparatorArray(array<string|int, mixed> $separators, int $count) : array<string|int, mixed>
Parameters
- $separators : array<string|int, mixed>
- $count : int
Return values
array<string|int, mixed>wrapLiteral()
protected
wrapLiteral(string $value) : string
Parameters
- $value : string
Return values
stringmapFormatBlocks()
private
mapFormatBlocks(string $value) : string
Parameters
- $value : string