|
7 | 7 | /**
|
8 | 8 | * Returns associative array with detailed info about given date/time.
|
9 | 9 | *
|
10 |
| - * @param string $format Format accepted by DateTime::createFromFormat. |
| 10 | + * @param string $format Format accepted by DateTimeImmutable::createFromFormat. |
11 | 11 | * @param string $datetime String representing the date/time.
|
12 | 12 | * @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns associative array with detailed info about given date/time.
|
| 13 | + * |
| 14 | + * The returned array has keys for year, |
| 15 | + * month, day, hour, |
| 16 | + * minute, second, |
| 17 | + * fraction, and is_localtime. |
| 18 | + * |
| 19 | + * If is_localtime is present then |
| 20 | + * zone_type indicates the type of timezone. For type |
| 21 | + * 1 (UTC offset) the zone, |
| 22 | + * is_dst fields are added; for type 2 |
| 23 | + * (abbreviation) the fields tz_abbr, |
| 24 | + * is_dst are added; and for type 3 |
| 25 | + * (timezone identifier) the tz_abbr, |
| 26 | + * tz_id are added. |
| 27 | + * |
| 28 | + * The array includes warning_count and |
| 29 | + * warnings fields. The first one indicate how many |
| 30 | + * warnings there were. |
| 31 | + * The keys of elements warnings array indicate the |
| 32 | + * position in the given datetime where the warning |
| 33 | + * occurred, with the string value describing the warning itself. An example |
| 34 | + * below shows such a warning. |
| 35 | + * |
| 36 | + * The array also contains error_count and |
| 37 | + * errors fields. The first one indicate how many errors |
| 38 | + * were found. |
| 39 | + * The keys of elements errors array indicate the |
| 40 | + * position in the given datetime where the error |
| 41 | + * occurred, with the string value describing the error itself. An example |
| 42 | + * below shows such an error. |
13 | 43 | * @throws DatetimeException
|
14 | 44 | *
|
15 | 45 | */
|
@@ -45,6 +75,43 @@ function date_parse_from_format(string $format, string $datetime): ?array
|
45 | 75 | * DateTimeImmutable::__construct.
|
46 | 76 | * @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns array with information about the parsed date/time
|
47 | 77 | * on success.
|
| 78 | + * |
| 79 | + * The returned array has keys for year, |
| 80 | + * month, day, hour, |
| 81 | + * minute, second, |
| 82 | + * fraction, and is_localtime. |
| 83 | + * |
| 84 | + * If is_localtime is present then |
| 85 | + * zone_type indicates the type of timezone. For type |
| 86 | + * 1 (UTC offset) the zone, |
| 87 | + * is_dst fields are added; for type 2 |
| 88 | + * (abbreviation) the fields tz_abbr, |
| 89 | + * is_dst are added; and for type 3 |
| 90 | + * (timezone identifier) the tz_abbr, |
| 91 | + * tz_id are added. |
| 92 | + * |
| 93 | + * If relative time elements are present in the |
| 94 | + * datetime string such as +3 days, |
| 95 | + * the then returned array includes a nested array with the key |
| 96 | + * relative. This array then contains the keys |
| 97 | + * year, month, day, |
| 98 | + * hour, minute, |
| 99 | + * second, and if necessary weekday, and |
| 100 | + * weekdays, depending on the string that was passed in. |
| 101 | + * |
| 102 | + * The array includes warning_count and |
| 103 | + * warnings fields. The first one indicate how many |
| 104 | + * warnings there were. |
| 105 | + * The keys of elements warnings array indicate the |
| 106 | + * position in the given datetime where the warning |
| 107 | + * occurred, with the string value describing the warning itself. |
| 108 | + * |
| 109 | + * The array also contains error_count and |
| 110 | + * errors fields. The first one indicate how many errors |
| 111 | + * were found. |
| 112 | + * The keys of elements errors array indicate the |
| 113 | + * position in the given datetime where the error |
| 114 | + * occurred, with the string value describing the error itself. |
48 | 115 | * @throws DatetimeException
|
49 | 116 | *
|
50 | 117 | */
|
@@ -98,15 +165,17 @@ function date_parse(string $datetime): ?array
|
98 | 165 | * civil_twilight_begin
|
99 | 166 | *
|
100 | 167 | *
|
101 |
| - * The start of the civil dawn (zenith angle = 96°). It ends at sunrise. |
| 168 | + * The start of the civil dawn (zenith angle = 96°). It ends at |
| 169 | + * sunrise. |
102 | 170 | *
|
103 | 171 | *
|
104 | 172 | *
|
105 | 173 | *
|
106 | 174 | * civil_twilight_end
|
107 | 175 | *
|
108 | 176 | *
|
109 |
| - * The end of the civil dusk (zenith angle = 96°). It starts at sunset. |
| 177 | + * The end of the civil dusk (zenith angle = 96°). It starts at |
| 178 | + * sunset. |
110 | 179 | *
|
111 | 180 | *
|
112 | 181 | *
|
@@ -377,11 +446,6 @@ function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, fl
|
377 | 446 | * if no timestamp is given. In other words, timestamp
|
378 | 447 | * is optional and defaults to the value of time.
|
379 | 448 | *
|
380 |
| - * Unix timestamps do not handle timezones. Use the |
381 |
| - * DateTimeImmutable class, and its |
382 |
| - * DateTimeInterface::format formatting method to |
383 |
| - * format date/time information with a timezone attached. |
384 |
| - * |
385 | 449 | * @param string $format Format accepted by DateTimeInterface::format.
|
386 | 450 | * @param int $timestamp The optional timestamp parameter is an
|
387 | 451 | * int Unix timestamp that defaults to the current
|
@@ -630,83 +694,11 @@ function idate(string $format, int $timestamp = null): int
|
630 | 694 | }
|
631 | 695 |
|
632 | 696 |
|
633 |
| -/** |
634 |
| - * Returns the Unix timestamp corresponding to the arguments |
635 |
| - * given. This timestamp is a long integer containing the number of |
636 |
| - * seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time |
637 |
| - * specified. |
638 |
| - * |
639 |
| - * Arguments may be left out in order from right to left; any |
640 |
| - * arguments thus omitted will be set to the current value according |
641 |
| - * to the local date and time. |
642 |
| - * |
643 |
| - * @param int $hour The number of the hour relative to the start of the day determined by |
644 |
| - * month, day and year. |
645 |
| - * Negative values reference the hour before midnight of the day in question. |
646 |
| - * Values greater than 23 reference the appropriate hour in the following day(s). |
647 |
| - * @param int $minute The number of the minute relative to the start of the hour. |
648 |
| - * Negative values reference the minute in the previous hour. |
649 |
| - * Values greater than 59 reference the appropriate minute in the following hour(s). |
650 |
| - * @param int $second The number of seconds relative to the start of the minute. |
651 |
| - * Negative values reference the second in the previous minute. |
652 |
| - * Values greater than 59 reference the appropriate second in the following minute(s). |
653 |
| - * @param int $month The number of the month relative to the end of the previous year. |
654 |
| - * Values 1 to 12 reference the normal calendar months of the year in question. |
655 |
| - * 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. |
656 |
| - * Values greater than 12 reference the appropriate month in the following year(s). |
657 |
| - * @param int $day The number of the day relative to the end of the previous month. |
658 |
| - * Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. |
659 |
| - * 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. |
660 |
| - * Values greater than the number of days in the relevant month reference the appropriate day in the following month(s). |
661 |
| - * @param int $year The number of the year, may be a two or four digit value, |
662 |
| - * with values between 0-69 mapping to 2000-2069 and 70-100 to |
663 |
| - * 1970-2000. On systems where time_t is a 32bit signed integer, as |
664 |
| - * most common today, the valid range for year |
665 |
| - * is somewhere between 1901 and 2038. |
666 |
| - * @return int mktime returns the Unix timestamp of the arguments |
667 |
| - * given. |
668 |
| - * If the arguments are invalid, the function returns FALSE. |
669 |
| - * @throws DatetimeException |
670 |
| - * |
671 |
| - */ |
672 |
| -function mktime(int $hour, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int |
673 |
| -{ |
674 |
| - error_clear_last(); |
675 |
| - if ($year !== null) { |
676 |
| - $safeResult = \mktime($hour, $minute, $second, $month, $day, $year); |
677 |
| - } elseif ($day !== null) { |
678 |
| - $safeResult = \mktime($hour, $minute, $second, $month, $day); |
679 |
| - } elseif ($month !== null) { |
680 |
| - $safeResult = \mktime($hour, $minute, $second, $month); |
681 |
| - } elseif ($second !== null) { |
682 |
| - $safeResult = \mktime($hour, $minute, $second); |
683 |
| - } elseif ($minute !== null) { |
684 |
| - $safeResult = \mktime($hour, $minute); |
685 |
| - } else { |
686 |
| - $safeResult = \mktime($hour); |
687 |
| - } |
688 |
| - if ($safeResult === false) { |
689 |
| - throw DatetimeException::createFromPhpError(); |
690 |
| - } |
691 |
| - return $safeResult; |
692 |
| -} |
693 |
| - |
694 |
| - |
695 | 697 | /**
|
696 | 698 | * Format the time and/or date according to locale settings. Month and weekday
|
697 | 699 | * names and other language-dependent strings respect the current locale set
|
698 | 700 | * with setlocale.
|
699 | 701 | *
|
700 |
| - * Not all conversion specifiers may be supported by your C library, in which |
701 |
| - * case they will not be supported by PHP's strftime. |
702 |
| - * Additionally, not all platforms support negative timestamps, so your |
703 |
| - * date range may be limited to no earlier than the Unix epoch. This means that |
704 |
| - * %e, %T, %R and, %D (and possibly others) - as well as dates prior to |
705 |
| - * Jan 1, 1970 - will not work on Windows, some Linux |
706 |
| - * distributions, and a few other operating systems. For Windows systems, a |
707 |
| - * complete overview of supported conversion specifiers can be found at |
708 |
| - * MSDN. |
709 |
| - * |
710 | 702 | * @param string $format
|
711 | 703 | * The following characters are recognized in the
|
712 | 704 | * format parameter string
|
|
0 commit comments