1 | <?php |
||
19 | class DateParser extends Base |
||
20 | { |
||
21 | const DATE_FORMAT = 'm/d/Y'; |
||
22 | const DATE_TIME_FORMAT = 'm/d/Y H:i'; |
||
23 | const TIME_FORMAT = 'H:i'; |
||
24 | |||
25 | /** |
||
26 | * Get date format from settings. |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | public function getUserDateFormat() |
||
34 | |||
35 | /** |
||
36 | * Get date time format from settings. |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | public function getUserDateTimeFormat() |
||
44 | |||
45 | /** |
||
46 | * Get time format from settings. |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | public function getUserTimeFormat() |
||
54 | |||
55 | /** |
||
56 | * List of time formats. |
||
57 | * |
||
58 | * @return string[] |
||
59 | */ |
||
60 | public function getTimeFormats() |
||
67 | |||
68 | /** |
||
69 | * List of date formats. |
||
70 | * |
||
71 | * @param bool $iso |
||
72 | * |
||
73 | * @return string[] |
||
74 | */ |
||
75 | public function getDateFormats($iso = false) |
||
101 | |||
102 | /** |
||
103 | * List of datetime formats. |
||
104 | * |
||
105 | * @param bool $iso |
||
106 | * |
||
107 | * @return string[] |
||
108 | */ |
||
109 | public function getDateTimeFormats($iso = false) |
||
123 | |||
124 | /** |
||
125 | * List of all date formats. |
||
126 | * |
||
127 | * @param bool $iso |
||
128 | * |
||
129 | * @return string[] |
||
130 | */ |
||
131 | public function getAllDateFormats($iso = false) |
||
135 | |||
136 | /** |
||
137 | * Get available formats (visible in settings). |
||
138 | * |
||
139 | * @param array $formats |
||
140 | * |
||
141 | * @return array |
||
142 | */ |
||
143 | public function getAvailableFormats(array $formats) |
||
153 | |||
154 | /** |
||
155 | * Get formats for date parsing. |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | public function getParserFormats() |
||
170 | |||
171 | /** |
||
172 | * Parse a date and return a unix timestamp, try different date formats. |
||
173 | * |
||
174 | * @param string $value Date to parse |
||
175 | * |
||
176 | * @return int |
||
177 | */ |
||
178 | public function getTimestamp($value) |
||
194 | |||
195 | /** |
||
196 | * Return a timestamp if the given date format is correct otherwise return 0. |
||
197 | * |
||
198 | * @param string $value Date to parse |
||
199 | * @param string $format Date format |
||
200 | * |
||
201 | * @return int |
||
202 | */ |
||
203 | private function getValidDate($value, $format) |
||
218 | |||
219 | /** |
||
220 | * Return true if the date is within the date range. |
||
221 | * |
||
222 | * @param DateTime $date |
||
223 | * @param DateTime $start |
||
224 | * @param DateTime $end |
||
225 | * |
||
226 | * @return bool |
||
227 | */ |
||
228 | public function withinDateRange(DateTime $date, DateTime $start, DateTime $end) |
||
232 | |||
233 | /** |
||
234 | * Get the total number of hours between 2 datetime objects |
||
235 | * Minutes are rounded to the nearest quarter. |
||
236 | * |
||
237 | * @param DateTime $d1 |
||
238 | * @param DateTime $d2 |
||
239 | * |
||
240 | * @return float |
||
241 | */ |
||
242 | public function getHours(DateTime $d1, DateTime $d2) |
||
248 | |||
249 | /** |
||
250 | * Get ISO-8601 date from user input. |
||
251 | * |
||
252 | * @param string $value Date to parse |
||
253 | * |
||
254 | * @return string |
||
255 | */ |
||
256 | public function getIsoDate($value) |
||
260 | |||
261 | /** |
||
262 | * Get a timestamp from an ISO date format. |
||
263 | * |
||
264 | * @param string $value |
||
265 | * |
||
266 | * @return int |
||
267 | */ |
||
268 | public function getTimestampFromIsoFormat($value) |
||
272 | |||
273 | /** |
||
274 | * Remove the time from a timestamp. |
||
275 | * |
||
276 | * @param int $timestamp |
||
277 | * |
||
278 | * @return int |
||
279 | */ |
||
280 | public function removeTimeFromTimestamp($timestamp) |
||
284 | |||
285 | /** |
||
286 | * Format date (form display). |
||
287 | * |
||
288 | * @param array $values Database values |
||
289 | * @param string[] $fields Date fields |
||
290 | * @param string $format Date format |
||
291 | * |
||
292 | * @return array |
||
293 | */ |
||
294 | public function format(array $values, array $fields, $format) |
||
310 | |||
311 | /** |
||
312 | * Convert date to timestamp. |
||
313 | * |
||
314 | * @param array $values Database values |
||
315 | * @param string[] $fields Date fields |
||
316 | * @param bool $keep_time Keep time or not |
||
317 | * |
||
318 | * @return array |
||
319 | */ |
||
320 | public function convert(array $values, array $fields, $keep_time = false) |
||
331 | } |
||
332 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.