PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.17.2 4.17.1 4.17.0 4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / third-party / vendor / thecodingmachine / safe / generated / datetime.php
wp-user-avatar / third-party / vendor / thecodingmachine / safe / generated Last commit date
Exceptions 5 days ago apache.php 5 days ago apcu.php 5 days ago array.php 5 days ago bzip2.php 5 days ago calendar.php 5 days ago classobj.php 5 days ago com.php 5 days ago cubrid.php 5 days ago curl.php 5 days ago datetime.php 5 days ago dir.php 5 days ago eio.php 5 days ago errorfunc.php 5 days ago exec.php 5 days ago fileinfo.php 5 days ago filesystem.php 5 days ago filter.php 5 days ago fpm.php 5 days ago ftp.php 5 days ago funchand.php 5 days ago functionsList.php 5 days ago gmp.php 5 days ago gnupg.php 5 days ago hash.php 5 days ago ibase.php 5 days ago ibmDb2.php 5 days ago iconv.php 5 days ago image.php 5 days ago imap.php 5 days ago info.php 5 days ago ingres-ii.php 5 days ago inotify.php 5 days ago json.php 5 days ago ldap.php 5 days ago libxml.php 5 days ago lzf.php 5 days ago mailparse.php 5 days ago mbstring.php 5 days ago misc.php 5 days ago msql.php 5 days ago mysql.php 5 days ago mysqli.php 5 days ago mysqlndMs.php 5 days ago mysqlndQc.php 5 days ago network.php 5 days ago oci8.php 5 days ago opcache.php 5 days ago openssl.php 5 days ago outcontrol.php 5 days ago password.php 5 days ago pcntl.php 5 days ago pcre.php 5 days ago pdf.php 5 days ago pgsql.php 5 days ago posix.php 5 days ago ps.php 5 days ago pspell.php 5 days ago readline.php 5 days ago rpminfo.php 5 days ago rrd.php 5 days ago sem.php 5 days ago session.php 5 days ago shmop.php 5 days ago simplexml.php 5 days ago sockets.php 5 days ago sodium.php 5 days ago solr.php 5 days ago spl.php 5 days ago sqlsrv.php 5 days ago ssdeep.php 5 days ago ssh2.php 5 days ago stream.php 5 days ago strings.php 5 days ago swoole.php 5 days ago uodbc.php 5 days ago uopz.php 5 days ago url.php 5 days ago var.php 5 days ago xdiff.php 5 days ago xml.php 5 days ago xmlrpc.php 5 days ago yaml.php 5 days ago yaz.php 5 days ago zip.php 5 days ago zlib.php 5 days ago
datetime.php
611 lines
1 <?php
2
3 namespace ProfilePressVendor\Safe;
4
5 use ProfilePressVendor\Safe\Exceptions\DatetimeException;
6 /**
7 * Returns associative array with detailed info about given date/time.
8 *
9 * @param string $format Format accepted by DateTime::createFromFormat.
10 * @param string $datetime String representing the date/time.
11 * @return array Returns associative array with detailed info about given date/time.
12 * @throws DatetimeException
13 *
14 */
15 function date_parse_from_format(string $format, string $datetime): array
16 {
17 error_clear_last();
18 $result = \date_parse_from_format($format, $datetime);
19 if ($result === \false) {
20 throw DatetimeException::createFromPhpError();
21 }
22 return $result;
23 }
24 /**
25 *
26 *
27 * @param string $datetime Date/time in format accepted by
28 * DateTimeImmutable::__construct.
29 * @return array Returns array with information about the parsed date/time
30 * on success.
31 * @throws DatetimeException
32 *
33 */
34 function date_parse(string $datetime): array
35 {
36 error_clear_last();
37 $result = \date_parse($datetime);
38 if ($result === \false) {
39 throw DatetimeException::createFromPhpError();
40 }
41 return $result;
42 }
43 /**
44 *
45 *
46 * @param int $timestamp Unix timestamp.
47 * @param float $latitude Latitude in degrees.
48 * @param float $longitude Longitude in degrees.
49 * @return array Returns array on success.
50 * The structure of the array is detailed in the following list:
51 *
52 *
53 *
54 * sunrise
55 *
56 *
57 * The timestamp of the sunrise (zenith angle = 90°35').
58 *
59 *
60 *
61 *
62 * sunset
63 *
64 *
65 * The timestamp of the sunset (zenith angle = 90°35').
66 *
67 *
68 *
69 *
70 * transit
71 *
72 *
73 * The timestamp when the sun is at its zenith, i.e. has reached its topmost
74 * point.
75 *
76 *
77 *
78 *
79 * civil_twilight_begin
80 *
81 *
82 * The start of the civil dawn (zenith angle = 96°). It ends at sunrise.
83 *
84 *
85 *
86 *
87 * civil_twilight_end
88 *
89 *
90 * The end of the civil dusk (zenith angle = 96°). It starts at sunset.
91 *
92 *
93 *
94 *
95 * nautical_twilight_begin
96 *
97 *
98 * The start of the nautical dawn (zenith angle = 102°). It ends at
99 * civil_twilight_begin.
100 *
101 *
102 *
103 *
104 * nautical_twilight_end
105 *
106 *
107 * The end of the nautical dusk (zenith angle = 102°). It starts at
108 * civil_twilight_end.
109 *
110 *
111 *
112 *
113 * astronomical_twilight_begin
114 *
115 *
116 * The start of the astronomical dawn (zenith angle = 108°). It ends at
117 * nautical_twilight_begin.
118 *
119 *
120 *
121 *
122 * astronomical_twilight_end
123 *
124 *
125 * The end of the astronomical dusk (zenith angle = 108°). It starts at
126 * nautical_twilight_end.
127 *
128 *
129 *
130 *
131 *
132 * The values of the array elements are either UNIX timestamps, FALSE if the
133 * sun is below the respective zenith for the whole day, or TRUE if the sun is
134 * above the respective zenith for the whole day.
135 * @throws DatetimeException
136 *
137 */
138 function date_sun_info(int $timestamp, float $latitude, float $longitude): array
139 {
140 error_clear_last();
141 $result = \date_sun_info($timestamp, $latitude, $longitude);
142 if ($result === \false) {
143 throw DatetimeException::createFromPhpError();
144 }
145 return $result;
146 }
147 /**
148 * date_sunrise returns the sunrise time for a given
149 * day (specified as a timestamp) and location.
150 *
151 * @param int $timestamp The timestamp of the day from which the sunrise
152 * time is taken.
153 * @param int $returnFormat
154 * returnFormat constants
155 *
156 *
157 *
158 * constant
159 * description
160 * example
161 *
162 *
163 *
164 *
165 * SUNFUNCS_RET_STRING
166 * returns the result as string
167 * 16:46
168 *
169 *
170 * SUNFUNCS_RET_DOUBLE
171 * returns the result as float
172 * 16.78243132
173 *
174 *
175 * SUNFUNCS_RET_TIMESTAMP
176 * returns the result as integer (timestamp)
177 * 1095034606
178 *
179 *
180 *
181 *
182 * @param float $latitude Defaults to North, pass in a negative value for South.
183 * See also: date.default_latitude
184 * @param float $longitude Defaults to East, pass in a negative value for West.
185 * See also: date.default_longitude
186 * @param float $zenith zenith is the angle between the center of the sun
187 * and a line perpendicular to earth's surface. It defaults to
188 * date.sunrise_zenith
189 *
190 * Common zenith angles
191 *
192 *
193 *
194 * Angle
195 * Description
196 *
197 *
198 *
199 *
200 * 90°50'
201 * Sunrise: the point where the sun becomes visible.
202 *
203 *
204 * 96°
205 * Civil twilight: conventionally used to signify the start of dawn.
206 *
207 *
208 * 102°
209 * Nautical twilight: the point at which the horizon starts being visible at sea.
210 *
211 *
212 * 108°
213 * Astronomical twilight: the point at which the sun starts being the source of any illumination.
214 *
215 *
216 *
217 *
218 * @param float $utcOffset Specified in hours.
219 * The utcOffset is ignored, if
220 * returnFormat is
221 * SUNFUNCS_RET_TIMESTAMP.
222 * @return mixed Returns the sunrise time in a specified returnFormat on
223 * success. One potential reason for failure is that the
224 * sun does not rise at all, which happens inside the polar circles for part of
225 * the year.
226 * @throws DatetimeException
227 *
228 */
229 function date_sunrise(int $timestamp, int $returnFormat = \SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0)
230 {
231 error_clear_last();
232 if ($utcOffset !== 0) {
233 $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset);
234 } elseif ($zenith !== null) {
235 $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude, $zenith);
236 } elseif ($longitude !== null) {
237 $result = \date_sunrise($timestamp, $returnFormat, $latitude, $longitude);
238 } elseif ($latitude !== null) {
239 $result = \date_sunrise($timestamp, $returnFormat, $latitude);
240 } else {
241 $result = \date_sunrise($timestamp, $returnFormat);
242 }
243 if ($result === \false) {
244 throw DatetimeException::createFromPhpError();
245 }
246 return $result;
247 }
248 /**
249 * date_sunset returns the sunset time for a given
250 * day (specified as a timestamp) and location.
251 *
252 * @param int $timestamp The timestamp of the day from which the sunset
253 * time is taken.
254 * @param int $returnFormat
255 * returnFormat constants
256 *
257 *
258 *
259 * constant
260 * description
261 * example
262 *
263 *
264 *
265 *
266 * SUNFUNCS_RET_STRING
267 * returns the result as string
268 * 16:46
269 *
270 *
271 * SUNFUNCS_RET_DOUBLE
272 * returns the result as float
273 * 16.78243132
274 *
275 *
276 * SUNFUNCS_RET_TIMESTAMP
277 * returns the result as integer (timestamp)
278 * 1095034606
279 *
280 *
281 *
282 *
283 * @param float $latitude Defaults to North, pass in a negative value for South.
284 * See also: date.default_latitude
285 * @param float $longitude Defaults to East, pass in a negative value for West.
286 * See also: date.default_longitude
287 * @param float $zenith zenith is the angle between the center of the sun
288 * and a line perpendicular to earth's surface. It defaults to
289 * date.sunset_zenith
290 *
291 * Common zenith angles
292 *
293 *
294 *
295 * Angle
296 * Description
297 *
298 *
299 *
300 *
301 * 90°50'
302 * Sunset: the point where the sun becomes invisible.
303 *
304 *
305 * 96°
306 * Civil twilight: conventionally used to signify the end of dusk.
307 *
308 *
309 * 102°
310 * Nautical twilight: the point at which the horizon ends being visible at sea.
311 *
312 *
313 * 108°
314 * Astronomical twilight: the point at which the sun ends being the source of any illumination.
315 *
316 *
317 *
318 *
319 * @param float $utcOffset Specified in hours.
320 * The utcOffset is ignored, if
321 * returnFormat is
322 * SUNFUNCS_RET_TIMESTAMP.
323 * @return mixed Returns the sunset time in a specified returnFormat on
324 * success. One potential reason for failure is that the
325 * sun does not set at all, which happens inside the polar circles for part of
326 * the year.
327 * @throws DatetimeException
328 *
329 */
330 function date_sunset(int $timestamp, int $returnFormat = \SUNFUNCS_RET_STRING, float $latitude = null, float $longitude = null, float $zenith = null, float $utcOffset = 0)
331 {
332 error_clear_last();
333 if ($utcOffset !== 0) {
334 $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith, $utcOffset);
335 } elseif ($zenith !== null) {
336 $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude, $zenith);
337 } elseif ($longitude !== null) {
338 $result = \date_sunset($timestamp, $returnFormat, $latitude, $longitude);
339 } elseif ($latitude !== null) {
340 $result = \date_sunset($timestamp, $returnFormat, $latitude);
341 } else {
342 $result = \date_sunset($timestamp, $returnFormat);
343 }
344 if ($result === \false) {
345 throw DatetimeException::createFromPhpError();
346 }
347 return $result;
348 }
349 /**
350 * Returns a string formatted according to the given format string using the
351 * given integer timestamp or the current time
352 * if no timestamp is given. In other words, timestamp
353 * is optional and defaults to the value of time.
354 *
355 * @param string $format Format accepted by DateTimeInterface::format.
356 * @param int $timestamp The optional timestamp parameter is an
357 * integer Unix timestamp that defaults to the current
358 * local time if a timestamp is not given. In other
359 * words, it defaults to the value of time.
360 * @return string Returns a formatted date string. If a non-numeric value is used for
361 * timestamp, FALSE is returned and an
362 * E_WARNING level error is emitted.
363 * @throws DatetimeException
364 *
365 */
366 function date(string $format, int $timestamp = null): string
367 {
368 error_clear_last();
369 if ($timestamp !== null) {
370 $result = \date($format, $timestamp);
371 } else {
372 $result = \date($format);
373 }
374 if ($result === \false) {
375 throw DatetimeException::createFromPhpError();
376 }
377 return $result;
378 }
379 /**
380 * Identical to the date function except that
381 * the time returned is Greenwich Mean Time (GMT).
382 *
383 * @param string $format The format of the outputted date string. See the formatting
384 * options for the date function.
385 * @param int $timestamp The optional timestamp parameter is an
386 * integer Unix timestamp that defaults to the current
387 * local time if a timestamp is not given. In other
388 * words, it defaults to the value of time.
389 * @return string Returns a formatted date string. If a non-numeric value is used for
390 * timestamp, FALSE is returned and an
391 * E_WARNING level error is emitted.
392 * @throws DatetimeException
393 *
394 */
395 function gmdate(string $format, int $timestamp = null): string
396 {
397 error_clear_last();
398 if ($timestamp !== null) {
399 $result = \gmdate($format, $timestamp);
400 } else {
401 $result = \gmdate($format);
402 }
403 if ($result === \false) {
404 throw DatetimeException::createFromPhpError();
405 }
406 return $result;
407 }
408 /**
409 * Returns the Unix timestamp corresponding to the arguments
410 * given. This timestamp is a long integer containing the number of
411 * seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time
412 * specified.
413 *
414 * Arguments may be left out in order from right to left; any
415 * arguments thus omitted will be set to the current value according
416 * to the local date and time.
417 *
418 * @param int $hour The number of the hour relative to the start of the day determined by
419 * month, day and year.
420 * Negative values reference the hour before midnight of the day in question.
421 * Values greater than 23 reference the appropriate hour in the following day(s).
422 * @param int $minute The number of the minute relative to the start of the hour.
423 * Negative values reference the minute in the previous hour.
424 * Values greater than 59 reference the appropriate minute in the following hour(s).
425 * @param int $second The number of seconds relative to the start of the minute.
426 * Negative values reference the second in the previous minute.
427 * Values greater than 59 reference the appropriate second in the following minute(s).
428 * @param int $month The number of the month relative to the end of the previous year.
429 * Values 1 to 12 reference the normal calendar months of the year in question.
430 * 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.
431 * Values greater than 12 reference the appropriate month in the following year(s).
432 * @param int $day The number of the day relative to the end of the previous month.
433 * Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month.
434 * 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.
435 * Values greater than the number of days in the relevant month reference the appropriate day in the following month(s).
436 * @param int $year The number of the year, may be a two or four digit value,
437 * with values between 0-69 mapping to 2000-2069 and 70-100 to
438 * 1970-2000. On systems where time_t is a 32bit signed integer, as
439 * most common today, the valid range for year
440 * is somewhere between 1901 and 2038. However, before PHP 5.1.0 this
441 * range was limited from 1970 to 2038 on some systems (e.g. Windows).
442 * @return int mktime returns the Unix timestamp of the arguments
443 * given.
444 * If the arguments are invalid, the function returns FALSE (before PHP 5.1
445 * it returned -1).
446 * @throws DatetimeException
447 *
448 */
449 function mktime(int $hour = null, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int
450 {
451 error_clear_last();
452 if ($year !== null) {
453 $result = \mktime($hour, $minute, $second, $month, $day, $year);
454 } elseif ($day !== null) {
455 $result = \mktime($hour, $minute, $second, $month, $day);
456 } elseif ($month !== null) {
457 $result = \mktime($hour, $minute, $second, $month);
458 } elseif ($second !== null) {
459 $result = \mktime($hour, $minute, $second);
460 } elseif ($minute !== null) {
461 $result = \mktime($hour, $minute);
462 } elseif ($hour !== null) {
463 $result = \mktime($hour);
464 } else {
465 $result = \mktime();
466 }
467 if ($result === \false) {
468 throw DatetimeException::createFromPhpError();
469 }
470 return $result;
471 }
472 /**
473 * strptime returns an array with the
474 * date parsed.
475 *
476 * Month and weekday names and other language dependent strings respect the
477 * current locale set with setlocale (LC_TIME).
478 *
479 * @param string $date The string to parse (e.g. returned from strftime).
480 * @param string $format The format used in date (e.g. the same as
481 * used in strftime). Note that some of the format
482 * options available to strftime may not have any
483 * effect within strptime; the exact subset that are
484 * supported will vary based on the operating system and C library in
485 * use.
486 *
487 * For more information about the format options, read the
488 * strftime page.
489 * @return array Returns an array.
490 *
491 *
492 * The following parameters are returned in the array
493 *
494 *
495 *
496 * parameters
497 * Description
498 *
499 *
500 *
501 *
502 * "tm_sec"
503 * Seconds after the minute (0-61)
504 *
505 *
506 * "tm_min"
507 * Minutes after the hour (0-59)
508 *
509 *
510 * "tm_hour"
511 * Hour since midnight (0-23)
512 *
513 *
514 * "tm_mday"
515 * Day of the month (1-31)
516 *
517 *
518 * "tm_mon"
519 * Months since January (0-11)
520 *
521 *
522 * "tm_year"
523 * Years since 1900
524 *
525 *
526 * "tm_wday"
527 * Days since Sunday (0-6)
528 *
529 *
530 * "tm_yday"
531 * Days since January 1 (0-365)
532 *
533 *
534 * "unparsed"
535 * the date part which was not
536 * recognized using the specified format
537 *
538 *
539 *
540 *
541 * @throws DatetimeException
542 *
543 */
544 function strptime(string $date, string $format): array
545 {
546 error_clear_last();
547 $result = \strptime($date, $format);
548 if ($result === \false) {
549 throw DatetimeException::createFromPhpError();
550 }
551 return $result;
552 }
553 /**
554 * Each parameter of this function uses the default time zone unless a
555 * time zone is specified in that parameter. Be careful not to use
556 * different time zones in each parameter unless that is intended.
557 * See date_default_timezone_get on the various
558 * ways to define the default time zone.
559 *
560 * @param string $datetime A date/time string. Valid formats are explained in Date and Time Formats.
561 * @param int $now The timestamp which is used as a base for the calculation of relative
562 * dates.
563 * @return int Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0,
564 * this function would return -1 on failure.
565 * @throws DatetimeException
566 *
567 */
568 function strtotime(string $datetime, int $now = null): int
569 {
570 error_clear_last();
571 if ($now !== null) {
572 $result = \strtotime($datetime, $now);
573 } else {
574 $result = \strtotime($datetime);
575 }
576 if ($result === \false) {
577 throw DatetimeException::createFromPhpError();
578 }
579 return $result;
580 }
581 /**
582 *
583 *
584 * @param string $abbr Time zone abbreviation.
585 * @param int $utcOffset Offset from GMT in seconds. Defaults to -1 which means that first found
586 * time zone corresponding to abbr is returned.
587 * Otherwise exact offset is searched and only if not found then the first
588 * time zone with any offset is returned.
589 * @param int $isDST Daylight saving time indicator. Defaults to -1, which means that
590 * whether the time zone has daylight saving or not is not taken into
591 * consideration when searching. If this is set to 1, then the
592 * utcOffset is assumed to be an offset with
593 * daylight saving in effect; if 0, then utcOffset
594 * is assumed to be an offset without daylight saving in effect. If
595 * abbr doesn't exist then the time zone is
596 * searched solely by the utcOffset and
597 * isDST.
598 * @return string Returns time zone name on success.
599 * @throws DatetimeException
600 *
601 */
602 function timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string
603 {
604 error_clear_last();
605 $result = \timezone_name_from_abbr($abbr, $utcOffset, $isDST);
606 if ($result === \false) {
607 throw DatetimeException::createFromPhpError();
608 }
609 return $result;
610 }
611