5
5
use Safe \Exceptions \DatetimeException ;
6
6
7
7
/**
8
- * Returns associative array with detailed info about given date.
8
+ * Returns associative array with detailed info about given date/time .
9
9
*
10
10
* @param string $format Format accepted by DateTime::createFromFormat.
11
- * @param string $date String representing the date.
12
- * @return array Returns associative array with detailed info about given date.
11
+ * @param string $datetime String representing the date/time .
12
+ * @return array Returns associative array with detailed info about given date/time .
13
13
* @throws DatetimeException
14
14
*
15
15
*/
16
- function date_parse_from_format (string $ format , string $ date ): array
16
+ function date_parse_from_format (string $ format , string $ datetime ): array
17
17
{
18
18
error_clear_last ();
19
- $ result = \date_parse_from_format ($ format , $ date );
19
+ $ result = \date_parse_from_format ($ format , $ datetime );
20
20
if ($ result === false ) {
21
21
throw DatetimeException::createFromPhpError ();
22
22
}
@@ -27,16 +27,17 @@ function date_parse_from_format(string $format, string $date): array
27
27
/**
28
28
*
29
29
*
30
- * @param string $date Date in format accepted by strtotime.
31
- * @return array Returns array with information about the parsed date
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
32
33
* on success.
33
34
* @throws DatetimeException
34
35
*
35
36
*/
36
- function date_parse (string $ date ): array
37
+ function date_parse (string $ datetime ): array
37
38
{
38
39
error_clear_last ();
39
- $ result = \date_parse ($ date );
40
+ $ result = \date_parse ($ datetime );
40
41
if ($ result === false ) {
41
42
throw DatetimeException::createFromPhpError ();
42
43
}
@@ -47,7 +48,7 @@ function date_parse(string $date): array
47
48
/**
48
49
*
49
50
*
50
- * @param int $time Timestamp .
51
+ * @param int $timestamp Unix timestamp .
51
52
* @param float $latitude Latitude in degrees.
52
53
* @param float $longitude Longitude in degrees.
53
54
* @return array Returns array on success.
@@ -58,23 +59,23 @@ function date_parse(string $date): array
58
59
* sunrise
59
60
*
60
61
*
61
- * The time of the sunrise (zenith angle = 90°35').
62
+ * The timestamp of the sunrise (zenith angle = 90°35').
62
63
*
63
64
*
64
65
*
65
66
*
66
67
* sunset
67
68
*
68
69
*
69
- * The time of the sunset (zenith angle = 90°35').
70
+ * The timestamp of the sunset (zenith angle = 90°35').
70
71
*
71
72
*
72
73
*
73
74
*
74
75
* transit
75
76
*
76
77
*
77
- * The time when the sun is at its zenith, i.e. has reached its topmost
78
+ * The timestamp when the sun is at its zenith, i.e. has reached its topmost
78
79
* point.
79
80
*
80
81
*
@@ -139,10 +140,10 @@ function date_parse(string $date): array
139
140
* @throws DatetimeException
140
141
*
141
142
*/
142
- function date_sun_info (int $ time , float $ latitude , float $ longitude ): array
143
+ function date_sun_info (int $ timestamp , float $ latitude , float $ longitude ): array
143
144
{
144
145
error_clear_last ();
145
- $ result = \date_sun_info ($ time , $ latitude , $ longitude );
146
+ $ result = \date_sun_info ($ timestamp , $ latitude , $ longitude );
146
147
if ($ result === false ) {
147
148
throw DatetimeException::createFromPhpError ();
148
149
}
@@ -156,8 +157,8 @@ function date_sun_info(int $time, float $latitude, float $longitude): array
156
157
*
157
158
* @param int $timestamp The timestamp of the day from which the sunrise
158
159
* time is taken.
159
- * @param int $format
160
- * format constants
160
+ * @param int $returnFormat
161
+ * returnFormat constants
161
162
*
162
163
*
163
164
*
@@ -221,30 +222,30 @@ function date_sun_info(int $time, float $latitude, float $longitude): array
221
222
*
222
223
*
223
224
*
224
- * @param float $gmt_offset Specified in hours.
225
- * The gmtoffset is ignored, if
226
- * format is
225
+ * @param float $utcOffset Specified in hours.
226
+ * The utcOffset is ignored, if
227
+ * returnFormat is
227
228
* SUNFUNCS_RET_TIMESTAMP.
228
- * @return mixed Returns the sunrise time in a specified format on
229
+ * @return mixed Returns the sunrise time in a specified returnFormat on
229
230
* success. One potential reason for failure is that the
230
231
* sun does not rise at all, which happens inside the polar circles for part of
231
232
* the year.
232
233
* @throws DatetimeException
233
234
*
234
235
*/
235
- function date_sunrise (int $ timestamp , int $ format = SUNFUNCS_RET_STRING , float $ latitude = null , float $ longitude = null , float $ zenith = null , float $ gmt_offset = 0 )
236
+ function date_sunrise (int $ timestamp , int $ returnFormat = SUNFUNCS_RET_STRING , float $ latitude = null , float $ longitude = null , float $ zenith = null , float $ utcOffset = 0 )
236
237
{
237
238
error_clear_last ();
238
- if ($ gmt_offset !== 0 ) {
239
- $ result = \date_sunrise ($ timestamp , $ format , $ latitude , $ longitude , $ zenith , $ gmt_offset );
239
+ if ($ utcOffset !== 0 ) {
240
+ $ result = \date_sunrise ($ timestamp , $ returnFormat , $ latitude , $ longitude , $ zenith , $ utcOffset );
240
241
} elseif ($ zenith !== null ) {
241
- $ result = \date_sunrise ($ timestamp , $ format , $ latitude , $ longitude , $ zenith );
242
+ $ result = \date_sunrise ($ timestamp , $ returnFormat , $ latitude , $ longitude , $ zenith );
242
243
} elseif ($ longitude !== null ) {
243
- $ result = \date_sunrise ($ timestamp , $ format , $ latitude , $ longitude );
244
+ $ result = \date_sunrise ($ timestamp , $ returnFormat , $ latitude , $ longitude );
244
245
} elseif ($ latitude !== null ) {
245
- $ result = \date_sunrise ($ timestamp , $ format , $ latitude );
246
+ $ result = \date_sunrise ($ timestamp , $ returnFormat , $ latitude );
246
247
} else {
247
- $ result = \date_sunrise ($ timestamp , $ format );
248
+ $ result = \date_sunrise ($ timestamp , $ returnFormat );
248
249
}
249
250
if ($ result === false ) {
250
251
throw DatetimeException::createFromPhpError ();
@@ -259,8 +260,8 @@ function date_sunrise(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $
259
260
*
260
261
* @param int $timestamp The timestamp of the day from which the sunset
261
262
* time is taken.
262
- * @param int $format
263
- * format constants
263
+ * @param int $returnFormat
264
+ * returnFormat constants
264
265
*
265
266
*
266
267
*
@@ -324,30 +325,30 @@ function date_sunrise(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $
324
325
*
325
326
*
326
327
*
327
- * @param float $gmt_offset Specified in hours.
328
- * The gmtoffset is ignored, if
329
- * format is
328
+ * @param float $utcOffset Specified in hours.
329
+ * The utcOffset is ignored, if
330
+ * returnFormat is
330
331
* SUNFUNCS_RET_TIMESTAMP.
331
- * @return mixed Returns the sunset time in a specified format on
332
+ * @return mixed Returns the sunset time in a specified returnFormat on
332
333
* success. One potential reason for failure is that the
333
334
* sun does not set at all, which happens inside the polar circles for part of
334
335
* the year.
335
336
* @throws DatetimeException
336
337
*
337
338
*/
338
- function date_sunset (int $ timestamp , int $ format = SUNFUNCS_RET_STRING , float $ latitude = null , float $ longitude = null , float $ zenith = null , float $ gmt_offset = 0 )
339
+ function date_sunset (int $ timestamp , int $ returnFormat = SUNFUNCS_RET_STRING , float $ latitude = null , float $ longitude = null , float $ zenith = null , float $ utcOffset = 0 )
339
340
{
340
341
error_clear_last ();
341
- if ($ gmt_offset !== 0 ) {
342
- $ result = \date_sunset ($ timestamp , $ format , $ latitude , $ longitude , $ zenith , $ gmt_offset );
342
+ if ($ utcOffset !== 0 ) {
343
+ $ result = \date_sunset ($ timestamp , $ returnFormat , $ latitude , $ longitude , $ zenith , $ utcOffset );
343
344
} elseif ($ zenith !== null ) {
344
- $ result = \date_sunset ($ timestamp , $ format , $ latitude , $ longitude , $ zenith );
345
+ $ result = \date_sunset ($ timestamp , $ returnFormat , $ latitude , $ longitude , $ zenith );
345
346
} elseif ($ longitude !== null ) {
346
- $ result = \date_sunset ($ timestamp , $ format , $ latitude , $ longitude );
347
+ $ result = \date_sunset ($ timestamp , $ returnFormat , $ latitude , $ longitude );
347
348
} elseif ($ latitude !== null ) {
348
- $ result = \date_sunset ($ timestamp , $ format , $ latitude );
349
+ $ result = \date_sunset ($ timestamp , $ returnFormat , $ latitude );
349
350
} else {
350
- $ result = \date_sunset ($ timestamp , $ format );
351
+ $ result = \date_sunset ($ timestamp , $ returnFormat );
351
352
}
352
353
if ($ result === false ) {
353
354
throw DatetimeException::createFromPhpError ();
@@ -512,21 +513,21 @@ function strptime(string $date, string $format): array
512
513
* See date_default_timezone_get on the various
513
514
* ways to define the default time zone.
514
515
*
515
- * @param string $time A date/time string. Valid formats are explained in Date and Time Formats.
516
+ * @param string $datetime A date/time string. Valid formats are explained in Date and Time Formats.
516
517
* @param int $now The timestamp which is used as a base for the calculation of relative
517
518
* dates.
518
519
* @return int Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0,
519
520
* this function would return -1 on failure.
520
521
* @throws DatetimeException
521
522
*
522
523
*/
523
- function strtotime (string $ time , int $ now = null ): int
524
+ function strtotime (string $ datetime , int $ now = null ): int
524
525
{
525
526
error_clear_last ();
526
527
if ($ now !== null ) {
527
- $ result = \strtotime ($ time , $ now );
528
+ $ result = \strtotime ($ datetime , $ now );
528
529
} else {
529
- $ result = \strtotime ($ time );
530
+ $ result = \strtotime ($ datetime );
530
531
}
531
532
if ($ result === false ) {
532
533
throw DatetimeException::createFromPhpError ();
@@ -539,27 +540,27 @@ function strtotime(string $time, int $now = null): int
539
540
*
540
541
*
541
542
* @param string $abbr Time zone abbreviation.
542
- * @param int $gmtOffset Offset from GMT in seconds. Defaults to -1 which means that first found
543
+ * @param int $utcOffset Offset from GMT in seconds. Defaults to -1 which means that first found
543
544
* time zone corresponding to abbr is returned.
544
545
* Otherwise exact offset is searched and only if not found then the first
545
546
* time zone with any offset is returned.
546
- * @param int $isdst Daylight saving time indicator. Defaults to -1, which means that
547
+ * @param int $isDST Daylight saving time indicator. Defaults to -1, which means that
547
548
* whether the time zone has daylight saving or not is not taken into
548
549
* consideration when searching. If this is set to 1, then the
549
- * gmtOffset is assumed to be an offset with
550
- * daylight saving in effect; if 0, then gmtOffset
550
+ * utcOffset is assumed to be an offset with
551
+ * daylight saving in effect; if 0, then utcOffset
551
552
* is assumed to be an offset without daylight saving in effect. If
552
553
* abbr doesn't exist then the time zone is
553
- * searched solely by the gmtOffset and
554
- * isdst .
554
+ * searched solely by the utcOffset and
555
+ * isDST .
555
556
* @return string Returns time zone name on success.
556
557
* @throws DatetimeException
557
558
*
558
559
*/
559
- function timezone_name_from_abbr (string $ abbr , int $ gmtOffset = -1 , int $ isdst = -1 ): string
560
+ function timezone_name_from_abbr (string $ abbr , int $ utcOffset = -1 , int $ isDST = -1 ): string
560
561
{
561
562
error_clear_last ();
562
- $ result = \timezone_name_from_abbr ($ abbr , $ gmtOffset , $ isdst );
563
+ $ result = \timezone_name_from_abbr ($ abbr , $ utcOffset , $ isDST );
563
564
if ($ result === false ) {
564
565
throw DatetimeException::createFromPhpError ();
565
566
}
0 commit comments