ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Data\DateFormat\DateFormat Class Reference

A Date Format provides a format definition akin to PHP's date formatting options, but stores the single elements/options as array to ease conversion into other formats. More...

+ Collaboration diagram for ILIAS\Data\DateFormat\DateFormat:

Public Member Functions

 __construct (array $format)
 
 validateFormatElelements (array $format)
 
 toArray ()
 Get the elements of the format as array. More...
 
 toString ()
 Get the format as string. More...
 
 __toString ()
 
 applyTo (\DateTimeImmutable $datetime)
 

Data Fields

const DOT = '.'
 
const COMMA = ','
 
const DASH = '-'
 
const SLASH = '/'
 
const SPACE = ' '
 
const DAY = 'd'
 
const DAY_ORDINAL = 'jS'
 
const WEEKDAY = 'l'
 
const WEEKDAY_SHORT = 'D'
 
const WEEK = 'W'
 
const MONTH = 'm'
 
const MONTH_SPELLED = 'F'
 
const MONTH_SPELLED_SHORT = 'M'
 
const YEAR = 'Y'
 
const YEAR_TWO_DIG = 'y'
 
const HOURS12 = 'h'
 
const HOURS24 = 'H'
 
const MINUTES = 'i'
 
const SECONDS = 's'
 
const MERIDIEM = 'a'
 
const COLON = ':'
 
const TOKENS
 

Protected Attributes

array $format = []
 

Detailed Description

A Date Format provides a format definition akin to PHP's date formatting options, but stores the single elements/options as array to ease conversion into other formats.

Definition at line 26 of file DateFormat.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\DateFormat\DateFormat::__construct ( array  $format)

Definition at line 77 of file DateFormat.php.

References ILIAS\Data\DateFormat\DateFormat\$format, and ILIAS\Data\DateFormat\DateFormat\validateFormatElelements().

78  {
80  $this->format = $format;
81  }
validateFormatElelements(array $format)
Definition: DateFormat.php:83
+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

ILIAS\Data\DateFormat\DateFormat::__toString ( )

Definition at line 109 of file DateFormat.php.

References ILIAS\Data\DateFormat\DateFormat\toString().

109  : string
110  {
111  return $this->toString();
112  }
toString()
Get the format as string.
Definition: DateFormat.php:104
+ Here is the call graph for this function:

◆ applyTo()

ILIAS\Data\DateFormat\DateFormat::applyTo ( \DateTimeImmutable  $datetime)

Definition at line 114 of file DateFormat.php.

References ILIAS\Data\DateFormat\DateFormat\toString().

114  : string
115  {
116  return $datetime->format($this->toString());
117  }
$datetime
toString()
Get the format as string.
Definition: DateFormat.php:104
+ Here is the call graph for this function:

◆ toArray()

ILIAS\Data\DateFormat\DateFormat::toArray ( )

Get the elements of the format as array.

Returns
string[]

Definition at line 96 of file DateFormat.php.

References ILIAS\Data\DateFormat\DateFormat\$format.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\initWithFormat().

96  : array
97  {
98  return $this->format;
99  }
+ Here is the caller graph for this function:

◆ toString()

ILIAS\Data\DateFormat\DateFormat::toString ( )

Get the format as string.

Definition at line 104 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\DateFormat\__toString(), and ILIAS\Data\DateFormat\DateFormat\applyTo().

104  : string
105  {
106  return implode('', $this->format);
107  }
+ Here is the caller graph for this function:

◆ validateFormatElelements()

ILIAS\Data\DateFormat\DateFormat::validateFormatElelements ( array  $format)

Definition at line 83 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\DateFormat\__construct().

83  : void
84  {
85  foreach ($format as $entry) {
86  if (!in_array($entry, self::TOKENS, true)) {
87  throw new \InvalidArgumentException("not a valid token for date-format", 1);
88  }
89  }
90  }
+ Here is the caller graph for this function:

Field Documentation

◆ $format

array ILIAS\Data\DateFormat\DateFormat::$format = []
protected

◆ COLON

const ILIAS\Data\DateFormat\DateFormat::COLON = ':'

Definition at line 48 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\colon().

◆ COMMA

const ILIAS\Data\DateFormat\DateFormat::COMMA = ','

Definition at line 29 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\comma().

◆ DASH

const ILIAS\Data\DateFormat\DateFormat::DASH = '-'

Definition at line 30 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\dash().

◆ DAY

const ILIAS\Data\DateFormat\DateFormat::DAY = 'd'

Definition at line 33 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\day().

◆ DAY_ORDINAL

const ILIAS\Data\DateFormat\DateFormat::DAY_ORDINAL = 'jS'

Definition at line 34 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\dayOrdinal().

◆ DOT

const ILIAS\Data\DateFormat\DateFormat::DOT = '.'

Definition at line 28 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\dot().

◆ HOURS12

const ILIAS\Data\DateFormat\DateFormat::HOURS12 = 'h'

Definition at line 43 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\hours12().

◆ HOURS24

const ILIAS\Data\DateFormat\DateFormat::HOURS24 = 'H'

Definition at line 44 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\hours24().

◆ MERIDIEM

const ILIAS\Data\DateFormat\DateFormat::MERIDIEM = 'a'

Definition at line 47 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\meridiem().

◆ MINUTES

const ILIAS\Data\DateFormat\DateFormat::MINUTES = 'i'

Definition at line 45 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\minutes().

◆ MONTH

const ILIAS\Data\DateFormat\DateFormat::MONTH = 'm'

Definition at line 38 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\month().

◆ MONTH_SPELLED

const ILIAS\Data\DateFormat\DateFormat::MONTH_SPELLED = 'F'

Definition at line 39 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\monthSpelled().

◆ MONTH_SPELLED_SHORT

const ILIAS\Data\DateFormat\DateFormat::MONTH_SPELLED_SHORT = 'M'

◆ SECONDS

const ILIAS\Data\DateFormat\DateFormat::SECONDS = 's'

Definition at line 46 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\seconds().

◆ SLASH

const ILIAS\Data\DateFormat\DateFormat::SLASH = '/'

Definition at line 31 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\slash().

◆ SPACE

const ILIAS\Data\DateFormat\DateFormat::SPACE = ' '

Definition at line 32 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\space().

◆ TOKENS

const ILIAS\Data\DateFormat\DateFormat::TOKENS
Initial value:
= [
self::DOT,
self::COMMA,
self::DASH,
self::SLASH,
self::SPACE,
self::DAY,
self::DAY_ORDINAL,
self::WEEKDAY,
self::WEEKDAY_SHORT,
self::WEEK,
self::MONTH,
self::MONTH_SPELLED,
self::MONTH_SPELLED_SHORT,
self::YEAR,
self::YEAR_TWO_DIG,
self::HOURS12,
self::HOURS24,
self::MINUTES,
self::SECONDS,
self::MERIDIEM,
self::COLON
]

Definition at line 50 of file DateFormat.php.

◆ WEEK

const ILIAS\Data\DateFormat\DateFormat::WEEK = 'W'

Definition at line 37 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\week().

◆ WEEKDAY

const ILIAS\Data\DateFormat\DateFormat::WEEKDAY = 'l'

Definition at line 35 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\weekday().

◆ WEEKDAY_SHORT

const ILIAS\Data\DateFormat\DateFormat::WEEKDAY_SHORT = 'D'

Definition at line 36 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\weekdayShort().

◆ YEAR

const ILIAS\Data\DateFormat\DateFormat::YEAR = 'Y'

Definition at line 41 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\year().

◆ YEAR_TWO_DIG

const ILIAS\Data\DateFormat\DateFormat::YEAR_TWO_DIG = 'y'

Definition at line 42 of file DateFormat.php.

Referenced by ILIAS\Data\DateFormat\FormatBuilder\twoDigitYear().


The documentation for this class was generated from the following file: