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