ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
FormatBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Data\DateFormat;
22
28{
30 private array $format = [];
31
35 public function get(): DateFormat
36 {
37 $df = new DateFormat($this->format);
38 $this->format = [];
39 return $df;
40 }
41
42 public function initWithFormat(DateFormat $format): self
43 {
44 $this->format = $format->toArray();
45 return $this;
46 }
47
51 public function dot(): self
52 {
53 $this->format[] = DateFormat::DOT;
54 return $this;
55 }
56
57 public function comma(): self
58 {
59 $this->format[] = DateFormat::COMMA;
60 return $this;
61 }
62
63 public function dash(): self
64 {
65 $this->format[] = DateFormat::DASH;
66 return $this;
67 }
68
69 public function slash(): self
70 {
71 $this->format[] = DateFormat::SLASH;
72 return $this;
73 }
74
75 public function space(): self
76 {
77 $this->format[] = DateFormat::SPACE;
78 return $this;
79 }
80
81 public function day(): self
82 {
83 $this->format[] = DateFormat::DAY;
84 return $this;
85 }
86
87 public function dayOrdinal(): self
88 {
89 $this->format[] = DateFormat::DAY_ORDINAL;
90 return $this;
91 }
92
93 public function weekday(): self
94 {
95 $this->format[] = DateFormat::WEEKDAY;
96 return $this;
97 }
98
99 public function weekdayShort(): self
100 {
101 $this->format[] = DateFormat::WEEKDAY_SHORT;
102 return $this;
103 }
104
105 public function week(): self
106 {
107 $this->format[] = DateFormat::WEEK;
108 return $this;
109 }
110
111 public function month(): self
112 {
113 $this->format[] = DateFormat::MONTH;
114 return $this;
115 }
116
117 public function monthSpelled(): self
118 {
119 $this->format[] = DateFormat::MONTH_SPELLED;
120 return $this;
121 }
122
123 public function monthSpelledShort(): self
124 {
125 $this->format[] = DateFormat::MONTH_SPELLED_SHORT;
126 return $this;
127 }
128
129 public function year(): self
130 {
131 $this->format[] = DateFormat::YEAR;
132 return $this;
133 }
134
135 public function twoDigitYear(): self
136 {
137 $this->format[] = DateFormat::YEAR_TWO_DIG;
138 return $this;
139 }
140
141 public function hours24(): FormatBuilder
142 {
143 $this->format[] = DateFormat::HOURS24;
144 return $this;
145 }
146
147 public function hours12(): FormatBuilder
148 {
149 $this->format[] = DateFormat::HOURS12;
150 return $this;
151 }
152
153 public function minutes(): FormatBuilder
154 {
155 $this->format[] = DateFormat::MINUTES;
156 return $this;
157 }
158
159 public function seconds(): FormatBuilder
160 {
161 $this->format[] = DateFormat::SECONDS;
162 return $this;
163 }
164
165 public function meridiem(): FormatBuilder
166 {
167 $this->format[] = DateFormat::MERIDIEM;
168 return $this;
169 }
170
171 public function colon(): FormatBuilder
172 {
173 $this->format[] = DateFormat::COLON;
174 return $this;
175 }
176}
A Date Format provides a format definition akin to PHP's date formatting options, but stores the sing...
Definition: DateFormat.php:28
Builds a Date Format with split up elements to ease conversion.
dot()
Append tokens to format.