PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.6.1
Defender Security – Malware Scanner, Login Security & Firewall v5.6.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / thecodingmachine / safe / generated / datetime.php

datetime.php in Defender Security – Malware Scanner, Login Security & Firewall 5.6.1, at vendor/thecodingmachine/safe/generated/datetime.php

632 lines 17.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Safe;
4
5 use Safe\Exceptions\DatetimeException;
6
7 /**
8 * Returns associative array with detailed info about given date/time.
9 *
10 * @param string $format Format accepted by DateTime::createFromFormat.
11 * @param string $datetime String representing the date/time.
12 * @return array Returns associative array with detailed info about given date/time.
13 * @throws DatetimeException
14 *
15 */
16 function date_parse_from_format(string $format, string $datetime): array
17 {
18 error_clear_last();
19 $result = \date_parse_from_format($format, $datetime);
20 if ($result === false) {
21 throw DatetimeException::createFromPhpError();
22 }
23 return $result;
24 }
25
26
27 /**
28 *
29 *
30 * @param string $datetime Date/time in format accepted by
31 * DateTimeImmutable::__construct.
32 * @return array Returns array with information about the parsed date/time
33 * on success.
34 * @throws DatetimeException
35 *
36 */
37 function date_parse(string $datetime): array
38 {
39 error_clear_last();
40 $result = \date_parse($datetime);
41 if ($result === false) {
42 throw DatetimeException::createFromPhpError();
43 }
44 return $result;
45 }
46
47
48 /**
49 *
50 *
51 * @param int $timestamp Unix timestamp.
52 * @param float $latitude Latitude in degrees.
53 * @param float $longitude Longitude in degrees.
54 * @return array Returns array on success.
55 * The structure of the array is detailed in the following list:
56 *
57 *
58 *
59 * sunrise
60 *
61 *
62 * The timestamp of the sunrise (zenith angle = 90°35').
63 *
64 *
65 *
66 *
67 * sunset
68 *
69 *
70 * The timestamp of the sunset (zenith angle = 90°35').
71 *
72 *
73 *
74 *
75 * transit
76 *
77 *
78 * The timestamp when the sun is at its zenith, i.e. has reached its topmost
79 * point.
80 *
81 *
82 *
83 *
84 * civil_twilight_begin
85 *
86 *
87 * The start of the civil dawn (zenith angle = 96°). It ends at sunrise.
88 *
89 *
90 *
91 *
92 * civil_twilight_end
93 *
94 *
95 * The end of the civil dusk (zenith angle = 96°). It starts at sunset.
96 *
97 *
98 *
99 *
100 * nautical_twilight_begin
101 *
102 *
103 * The start of the nautical dawn (zenith angle = 102°). It ends at
104 * civil_twilight_begin.
105 *
106 *
107 *
108 *
109 * nautical_twilight_end
110 *
111 *
112 * The end of the nautical dusk (zenith angle = 102°). It starts at
113 * civil_twilight_end.
114 *
115 *
116 *
117 *
118 * astronomical_twilight_begin
119 *
120 *
121 * The start of the astronomical dawn (zenith angle = 108°). It ends at
122 * nautical_twilight_begin.
123 *
124 *
125 *
126 *
127 * astronomical_twilight_end
128 *
129 *
130 * The end of the astronomical dusk (zenith angle = 108°). It starts at
131 * nautical_twilight_end.
132 *
133 *
134 *
135 *
136 *
137 * The values of the array elements are either UNIX timestamps, FALSE if the
138 * sun is below the respective zenith for the whole day, or TRUE if the sun is
139 * above the respective zenith for the whole day.
140 * @throws DatetimeException
141 *
142 */
143 function date_sun_info(int $timestamp, float $latitude, float $longitude): array
144 {
145 error_clear_last();
146 $result = \date_sun_info($timestamp, $latitude, $longitude);
147 if ($result === false) {
148 throw DatetimeException::createFromPhpError();
149 }
150 return $result;
151 }
152
153
154 /**
155 * date_sunrise returns the sunrise time for a given
156 * day (specified as a timestamp) and location.
157 *
158 * @param int $timestamp The timestamp of the day from which the sunrise
159 * time is taken.
160 * @param int $returnFormat
161 * returnFormat constants
162 *
163 *
164 *
165 * constant
166 * description
167 * example
168 *
169 *
170 *
171 *
172 * SUNFUNCS_RET_STRING
173 * returns the result as string
174 * 16:46
175 *
176 *
177 * SUNFUNCS_RET_DOUBLE
178 * returns the result as float
179 * 16.78243132
180 *
181 *
182 * SUNFUNCS_RET_TIMESTAMP
183 * returns the result as integer (timestamp)
184 * 1095034606
185 *
186 *
187 *
188 *
189 * @param float $latitude Defaults to North, pass in a negative value for South.
190 * See also: date.default_latitude
191 * @param float $longitude Defaults to East, pass in a negative value for West.
192 * See also: date.default_longitude
193 * @param float $zenith zenith is the angle between the center of the sun
194 * and a line perpendicular to earth's surface. It defaults to
195 * date.sunrise_zenith
196 *
197 * Common zenith angles
198 *
199 *
200 *
201 * Angle
202 * Description
203 *
204 *
205 *
206 *
207 * 90°50'
208 * Sunrise: the point where the sun becomes visible.
209 *
210 *
211 * 96°
212 * Civil twilight: conventionally used to signify the start of dawn.
213 *
214 *
215 * 102°
216 * Nautical twilight: the point at which the horizon starts being visible at sea.
217 *
218 *
219 * 108°
220 * Astronomical twilight: the point at which the sun starts being the source of any illumination.
221 *
222 *
223 *
224 *
225 * @param float $utcOffset Specified in hours.
226 * The utcOffset is ignored, if
227 * returnFormat is
228 * SUNFUNCS_RET_TIMESTAMP.
229 * @return mixed Returns the sunrise time in a specified returnFormat on
230 * success. One potential reason for failure is that the
231 * sun does not rise at all, which happens inside the polar circles for part of
232 * the year.
233 * @throws DatetimeException
234 *
235 */
236 function date_sunrise(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0)
237 {
238 error_clear_last();
239 if ($utcOffset !== 0) {
240 $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset);
241 } elseif ($zenith !== null) {
242 $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith);
243 } elseif ($longitude !== null) {
244 $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude);
245 } elseif ($latitude !== null) {
246 $result = \date_sunrise($timestamp, $returnFormat, $latitude);
247 } else {
248 $result = \date_sunrise($timestamp, $returnFormat);
249 }
250 if ($result === false) {
251 throw DatetimeException::createFromPhpError();
252 }
253 return $result;
254 }
255
256
257 /**
258 * date_sunset returns the sunset time for a given
259 * day (specified as a timestamp) and location.
260 *
261 * @param int $timestamp The timestamp of the day from which the sunset
262 * time is taken.
263 * @param int $returnFormat
264 * returnFormat constants
265 *
266 *
267 *
268 * constant
269 * description
270 * example
271 *
272 *
273 *
274 *
275 * SUNFUNCS_RET_STRING
276 * returns the result as string
277 * 16:46
278 *
279 *
280 * SUNFUNCS_RET_DOUBLE
281 * returns the result as float
282 * 16.78243132
283 *
284 *
285 * SUNFUNCS_RET_TIMESTAMP
286 * returns the result as integer (timestamp)
287 * 1095034606
288 *
289 *
290 *
291 *
292 * @param float $latitude Defaults to North, pass in a negative value for South.
293 * See also: date.default_latitude
294 * @param float $longitude Defaults to East, pass in a negative value for West.
295 * See also: date.default_longitude
296 * @param float $zenith zenith is the angle between the center of the sun
297 * and a line perpendicular to earth's surface. It defaults to
298 * date.sunset_zenith
299 *
300 * Common zenith angles
301 *
302 *
303 *
304 * Angle
305 * Description
306 *
307 *
308 *
309 *
310 * 90°50'
311 * Sunset: the point where the sun becomes invisible.
312 *
313 *
314 * 96°
315 * Civil twilight: conventionally used to signify the end of dusk.
316 *
317 *
318 * 102°
319 * Nautical twilight: the point at which the horizon ends being visible at sea.
320 *
321 *
322 * 108°
323 * Astronomical twilight: the point at which the sun ends being the source of any illumination.
324 *
325 *
326 *
327 *
328 * @param float $utcOffset Specified in hours.
329 * The utcOffset is ignored, if
330 * returnFormat is
331 * SUNFUNCS_RET_TIMESTAMP.
332 * @return mixed Returns the sunset time in a specified returnFormat on
333 * success. One potential reason for failure is that the
334 * sun does not set at all, which happens inside the polar circles for part of
335 * the year.
336 * @throws DatetimeException
337 *
338 */
339 function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0)
340 {
341 error_clear_last();
342 if ($utcOffset !== 0) {
343 $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset);
344 } elseif ($zenith !== null) {
345 $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith);
346 } elseif ($longitude !== null) {
347 $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude);
348 } elseif ($latitude !== null) {
349 $result = \date_sunset($timestamp, $returnFormat, $latitude);
350 } else {
351 $result = \date_sunset($timestamp, $returnFormat);
352 }
353 if ($result === false) {
354 throw DatetimeException::createFromPhpError();
355 }
356 return $result;
357 }
358
359
360 /**
361 * Returns a string formatted according to the given format string using the
362 * given integer timestamp or the current time
363 * if no timestamp is given. In other words, timestamp
364 * is optional and defaults to the value of time.
365 *
366 * @param string $format Format accepted by DateTimeInterface::format.
367 * @param int $timestamp The optional timestamp parameter is an
368 * integer Unix timestamp that defaults to the current
369 * local time if a timestamp is not given. In other
370 * words, it defaults to the value of time.
371 * @return string Returns a formatted date string. If a non-numeric value is used for
372 * timestamp, FALSE is returned and an
373 * E_WARNING level error is emitted.
374 * @throws DatetimeException
375 *
376 */
377 function date(string $format, int $timestamp = null): string
378 {
379 error_clear_last();
380 if ($timestamp !== null) {
381 $result = \date($format, $timestamp);
382 } else {
383 $result = \date($format);
384 }
385 if ($result === false) {
386 throw DatetimeException::createFromPhpError();
387 }
388 return $result;
389 }
390
391
392 /**
393 * Identical to the date function except that
394 * the time returned is Greenwich Mean Time (GMT).
395 *
396 * @param string $format The format of the outputted date string. See the formatting
397 * options for the date function.
398 * @param int $timestamp The optional timestamp parameter is an
399 * integer Unix timestamp that defaults to the current
400 * local time if a timestamp is not given. In other
401 * words, it defaults to the value of time.
402 * @return string Returns a formatted date string. If a non-numeric value is used for
403 * timestamp, FALSE is returned and an
404 * E_WARNING level error is emitted.
405 * @throws DatetimeException
406 *
407 */
408 function gmdate(string $format, int $timestamp = null): string
409 {
410 error_clear_last();
411 if ($timestamp !== null) {
412 $result = \gmdate($format, $timestamp);
413 } else {
414 $result = \gmdate($format);
415 }
416 if ($result === false) {
417 throw DatetimeException::createFromPhpError();
418 }
419 return $result;
420 }
421
422
423 /**
424 * Returns the Unix timestamp corresponding to the arguments
425 * given. This timestamp is a long integer containing the number of
426 * seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time
427 * specified.
428 *
429 * Arguments may be left out in order from right to left; any
430 * arguments thus omitted will be set to the current value according
431 * to the local date and time.
432 *
433 * @param int $hour The number of the hour relative to the start of the day determined by
434 * month, day and year.
435 * Negative values reference the hour before midnight of the day in question.
436 * Values greater than 23 reference the appropriate hour in the following day(s).
437 * @param int $minute The number of the minute relative to the start of the hour.
438 * Negative values reference the minute in the previous hour.
439 * Values greater than 59 reference the appropriate minute in the following hour(s).
440 * @param int $second The number of seconds relative to the start of the minute.
441 * Negative values reference the second in the previous minute.
442 * Values greater than 59 reference the appropriate second in the following minute(s).
443 * @param int $month The number of the month relative to the end of the previous year.
444 * Values 1 to 12 reference the normal calendar months of the year in question.
445 * Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc.
446 * Values greater than 12 reference the appropriate month in the following year(s).
447 * @param int $day The number of the day relative to the end of the previous month.
448 * Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month.
449 * Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc.
450 * Values greater than the number of days in the relevant month reference the appropriate day in the following month(s).
451 * @param int $year The number of the year, may be a two or four digit value,
452 * with values between 0-69 mapping to 2000-2069 and 70-100 to
453 * 1970-2000. On systems where time_t is a 32bit signed integer, as
454 * most common today, the valid range for year
455 * is somewhere between 1901 and 2038. However, before PHP 5.1.0 this
456 * range was limited from 1970 to 2038 on some systems (e.g. Windows).
457 * @return int mktime returns the Unix timestamp of the arguments
458 * given.
459 * If the arguments are invalid, the function returns FALSE (before PHP 5.1
460 * it returned -1).
461 * @throws DatetimeException
462 *
463 */
464 function mktime(int $hour = null, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int
465 {
466 error_clear_last();
467 if ($year !== null) {
468 $result = \mktime($hour, $minute, $second, $month, $day, $year);
469 } elseif ($day !== null) {
470 $result = \mktime($hour, $minute, $second, $month, $day);
471 } elseif ($month !== null) {
472 $result = \mktime($hour, $minute, $second, $month);
473 } elseif ($second !== null) {
474 $result = \mktime($hour, $minute, $second);
475 } elseif ($minute !== null) {
476 $result = \mktime($hour, $minute);
477 } elseif ($hour !== null) {
478 $result = \mktime($hour);
479 } else {
480 $result = \mktime();
481 }
482 if ($result === false) {
483 throw DatetimeException::createFromPhpError();
484 }
485 return $result;
486 }
487
488
489 /**
490 * strptime returns an array with the
491 * date parsed.
492 *
493 * Month and weekday names and other language dependent strings respect the
494 * current locale set with setlocale (LC_TIME).
495 *
496 * @param string $date The string to parse (e.g. returned from strftime).
497 * @param string $format The format used in date (e.g. the same as
498 * used in strftime). Note that some of the format
499 * options available to strftime may not have any
500 * effect within strptime; the exact subset that are
501 * supported will vary based on the operating system and C library in
502 * use.
503 *
504 * For more information about the format options, read the
505 * strftime page.
506 * @return array Returns an array.
507 *
508 *
509 * The following parameters are returned in the array
510 *
511 *
512 *
513 * parameters
514 * Description
515 *
516 *
517 *
518 *
519 * "tm_sec"
520 * Seconds after the minute (0-61)
521 *
522 *
523 * "tm_min"
524 * Minutes after the hour (0-59)
525 *
526 *
527 * "tm_hour"
528 * Hour since midnight (0-23)
529 *
530 *
531 * "tm_mday"
532 * Day of the month (1-31)
533 *
534 *
535 * "tm_mon"
536 * Months since January (0-11)
537 *
538 *
539 * "tm_year"
540 * Years since 1900
541 *
542 *
543 * "tm_wday"
544 * Days since Sunday (0-6)
545 *
546 *
547 * "tm_yday"
548 * Days since January 1 (0-365)
549 *
550 *
551 * "unparsed"
552 * the date part which was not
553 * recognized using the specified format
554 *
555 *
556 *
557 *
558 * @throws DatetimeException
559 *
560 */
561 function strptime(string $date, string $format): array
562 {
563 error_clear_last();
564 $result = \strptime($date, $format);
565 if ($result === false) {
566 throw DatetimeException::createFromPhpError();
567 }
568 return $result;
569 }
570
571
572 /**
573 * Each parameter of this function uses the default time zone unless a
574 * time zone is specified in that parameter. Be careful not to use
575 * different time zones in each parameter unless that is intended.
576 * See date_default_timezone_get on the various
577 * ways to define the default time zone.
578 *
579 * @param string $datetime A date/time string. Valid formats are explained in Date and Time Formats.
580 * @param int $now The timestamp which is used as a base for the calculation of relative
581 * dates.
582 * @return int Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0,
583 * this function would return -1 on failure.
584 * @throws DatetimeException
585 *
586 */
587 function strtotime(string $datetime, int $now = null): int
588 {
589 error_clear_last();
590 if ($now !== null) {
591 $result = \strtotime($datetime, $now);
592 } else {
593 $result = \strtotime($datetime);
594 }
595 if ($result === false) {
596 throw DatetimeException::createFromPhpError();
597 }
598 return $result;
599 }
600
601
602 /**
603 *
604 *
605 * @param string $abbr Time zone abbreviation.
606 * @param int $utcOffset Offset from GMT in seconds. Defaults to -1 which means that first found
607 * time zone corresponding to abbr is returned.
608 * Otherwise exact offset is searched and only if not found then the first
609 * time zone with any offset is returned.
610 * @param int $isDST Daylight saving time indicator. Defaults to -1, which means that
611 * whether the time zone has daylight saving or not is not taken into
612 * consideration when searching. If this is set to 1, then the
613 * utcOffset is assumed to be an offset with
614 * daylight saving in effect; if 0, then utcOffset
615 * is assumed to be an offset without daylight saving in effect. If
616 * abbr doesn't exist then the time zone is
617 * searched solely by the utcOffset and
618 * isDST.
619 * @return string Returns time zone name on success.
620 * @throws DatetimeException
621 *
622 */
623 function timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string
624 {
625 error_clear_last();
626 $result = \timezone_name_from_abbr($abbr, $utcOffset, $isDST);
627 if ($result === false) {
628 throw DatetimeException::createFromPhpError();
629 }
630 return $result;
631 }
632