xref: /PHP-8.1/ext/date/php_date.stub.php (revision 5fbba9b9)
1<?php
2
3/** @generate-class-entries */
4
5function strtotime(string $datetime, ?int $baseTimestamp = null): int|false {}
6
7/** @refcount 1 */
8function date(string $format, ?int $timestamp = null): string {}
9
10function idate(string $format, ?int $timestamp = null): int|false {}
11
12/** @refcount 1 */
13function gmdate(string $format, ?int $timestamp = null): string {}
14
15function mktime(
16    int $hour, ?int $minute = null, ?int $second = null,
17    ?int $month = null, ?int $day = null, ?int $year = null): int|false {}
18
19function gmmktime(
20    int $hour, ?int $minute = null, ?int $second = null,
21    ?int $month = null, ?int $day = null, ?int $year = null): int|false {}
22
23function checkdate(int $month, int $day, int $year): bool {}
24
25/**
26 * @refcount 1
27 * @deprecated
28 */
29function strftime(string $format, ?int $timestamp = null): string|false {}
30
31/**
32 * @refcount 1
33 * @deprecated
34 */
35function gmstrftime(string $format, ?int $timestamp = null): string|false {}
36
37function time(): int {}
38
39/**
40 * @return array<int|string, int>
41 * @refcount 1
42 */
43function localtime(?int $timestamp = null, bool $associative = false): array {}
44
45/**
46 * @return array<int|string, int|string>
47 * @refcount 1
48 */
49function getdate(?int $timestamp = null): array {}
50
51/** @refcount 1 */
52function date_create(string $datetime = "now", ?DateTimeZone $timezone = null): DateTime|false {}
53
54/** @refcount 1 */
55function date_create_immutable(
56    string $datetime = "now", ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
57
58/** @refcount 1 */
59function date_create_from_format(
60    string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false {}
61
62/** @refcount 1 */
63function date_create_immutable_from_format(
64    string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
65
66/**
67 * @return array<string, mixed>
68 * @refcount 1
69 */
70function date_parse(string $datetime): array {}
71
72/**
73 * @return array<string, mixed>
74 * @refcount 1
75 */
76function date_parse_from_format(string $format, string $datetime): array {}
77
78/**
79 * @return array<string, int|array>|false
80 * @refcount 1
81 */
82function date_get_last_errors(): array|false {}
83
84/** @refcount 1 */
85function date_format(DateTimeInterface $object, string $format): string {}
86
87function date_modify(DateTime $object, string $modifier): DateTime|false {}
88
89function date_add(DateTime $object, DateInterval $interval): DateTime {}
90
91function date_sub(DateTime $object, DateInterval $interval): DateTime {}
92
93/** @refcount 1 */
94function date_timezone_get(DateTimeInterface $object): DateTimeZone|false {}
95
96function date_timezone_set(DateTime $object, DateTimeZone $timezone): DateTime {}
97
98function date_offset_get(DateTimeInterface $object): int {}
99
100/** @refcount 1 */
101function date_diff(
102    DateTimeInterface $baseObject, DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
103
104function date_time_set(
105    DateTime $object, int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
106
107function date_date_set(DateTime $object, int $year, int $month, int $day): DateTime {}
108
109function date_isodate_set(DateTime $object, int $year, int $week, int $dayOfWeek = 1): DateTime {}
110
111function date_timestamp_set(DateTime $object, int $timestamp): DateTime {}
112
113function date_timestamp_get(DateTimeInterface $object): int {}
114
115/** @refcount 1 */
116function timezone_open(string $timezone): DateTimeZone|false {}
117
118/** @refcount 1 */
119function timezone_name_get(DateTimeZone $object): string {}
120
121/** @refcount 1 */
122function timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string|false {}
123
124function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime): int {}
125
126/**
127 * @return array<int, array>|false
128 * @refcount 1
129 */
130function timezone_transitions_get(
131    DateTimeZone $object, int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {}
132
133/**
134 * @return array<string, float|string>|false
135 * @refcount 1
136 */
137function timezone_location_get(DateTimeZone $object): array|false {}
138
139/**
140 * @return array<int, string>
141 * @refcount 1
142 */
143function timezone_identifiers_list(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array {}
144
145/**
146 * @return array<string, array>
147 * @refcount 1
148 */
149function timezone_abbreviations_list(): array {}
150
151/** @refcount 1 */
152function timezone_version_get(): string {}
153
154/** @refcount 1 */
155function date_interval_create_from_date_string(string $datetime): DateInterval|false {}
156
157/** @refcount 1 */
158function date_interval_format(DateInterval $object, string $format): string {}
159
160function date_default_timezone_set(string $timezoneId): bool {}
161
162/** @refcount 1 */
163function date_default_timezone_get(): string {}
164
165/**
166 * @refcount 1
167 * @deprecated
168 */
169function date_sunrise(
170    int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
171    ?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
172    ?float $utcOffset = null): string|int|float|false {}
173
174/**
175 * @refcount 1
176 * @deprecated
177 */
178function date_sunset(
179    int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
180    ?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
181    ?float $utcOffset = null): string|int|float|false {}
182
183/**
184 * @return array<string, bool|int>
185 * @refcount 1
186 */
187function date_sun_info(int $timestamp, float $latitude, float $longitude): array {}
188
189interface DateTimeInterface
190{
191    /** @tentative-return-type */
192    public function format(string $format): string;
193
194    /** @tentative-return-type */
195    public function getTimezone(): DateTimeZone|false;
196
197    /** @tentative-return-type */
198    public function getOffset(): int;
199
200    /** @tentative-return-type */
201    public function getTimestamp(): int;
202
203    /** @tentative-return-type */
204    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval;
205
206    /** @tentative-return-type */
207    public function __wakeup(): void;
208}
209
210class DateTime implements DateTimeInterface
211{
212    public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
213
214    /** @tentative-return-type */
215    public function __wakeup(): void {}
216
217    /** @tentative-return-type */
218    public static function __set_state(array $array): DateTime {}
219
220    /** @tentative-return-type */
221    public static function createFromImmutable(DateTimeImmutable $object): DateTime {}
222
223    public static function createFromInterface(DateTimeInterface $object): DateTime {}
224
225    /**
226     * @tentative-return-type
227     * @alias date_create_from_format
228     */
229    public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false {}
230
231    /**
232     * @return array<string, int|array>|false
233     * @tentative-return-type
234     * @alias date_get_last_errors
235     */
236    public static function getLastErrors(): array|false {}
237
238    /**
239     * @tentative-return-type
240     * @alias date_format
241     */
242    public function format(string $format): string {}
243
244    /**
245     * @tentative-return-type
246     * @alias date_modify
247     */
248    public function modify(string $modifier): DateTime|false {}
249
250    /**
251     * @tentative-return-type
252     * @alias date_add
253     */
254    public function add(DateInterval $interval): DateTime {}
255
256    /**
257     * @tentative-return-type
258     * @alias date_sub
259     */
260    public function sub(DateInterval $interval): DateTime {}
261
262    /**
263     * @tentative-return-type
264     * @alias date_timezone_get
265     */
266    public function getTimezone(): DateTimeZone|false {}
267
268    /**
269     * @tentative-return-type
270     * @alias date_timezone_set
271     */
272    public function setTimezone(DateTimeZone $timezone): DateTime {}
273
274    /**
275     * @tentative-return-type
276     * @alias date_offset_get
277     */
278    public function getOffset(): int {}
279
280    /**
281     * @tentative-return-type
282     * @alias date_time_set
283     */
284    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
285
286    /**
287     * @tentative-return-type
288     * @alias date_date_set
289     */
290    public function setDate(int $year, int $month, int $day): DateTime {}
291
292    /**
293     * @tentative-return-type
294     * @alias date_isodate_set
295     */
296    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTime {}
297
298    /**
299     * @tentative-return-type
300     * @alias date_timestamp_set
301     */
302    public function setTimestamp(int $timestamp): DateTime {}
303
304    /**
305     * @tentative-return-type
306     * @alias date_timestamp_get
307     */
308    public function getTimestamp(): int {}
309
310    /**
311     * @tentative-return-type
312     * @alias date_diff
313     */
314    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
315}
316
317class DateTimeImmutable implements DateTimeInterface
318{
319    public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
320
321    /** @tentative-return-type */
322    public function __wakeup(): void {}
323
324    /** @tentative-return-type */
325    public static function __set_state(array $array): DateTimeImmutable {}
326
327    /**
328     * @tentative-return-type
329     * @alias date_create_immutable_from_format
330     */
331    public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
332
333    /**
334     * @return array<string, int|array>|false
335     * @tentative-return-type
336     * @alias date_get_last_errors
337     */
338    public static function getLastErrors(): array|false {}
339
340    /**
341     * @tentative-return-type
342     * @alias date_format
343     */
344    public function format(string $format): string {}
345
346    /**
347     * @tentative-return-type
348     * @alias date_timezone_get
349     */
350    public function getTimezone(): DateTimeZone|false {}
351
352    /**
353     * @tentative-return-type
354     * @alias date_offset_get
355     */
356    public function getOffset(): int {}
357
358    /**
359     * @tentative-return-type
360     * @alias date_timestamp_get
361     */
362    public function getTimestamp(): int {}
363
364    /**
365     * @tentative-return-type
366     * @alias date_diff
367     */
368    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
369
370    /** @tentative-return-type */
371    public function modify(string $modifier): DateTimeImmutable|false {}
372
373    /** @tentative-return-type */
374    public function add(DateInterval $interval): DateTimeImmutable {}
375
376    /** @tentative-return-type */
377    public function sub(DateInterval $interval): DateTimeImmutable {}
378
379    /** @tentative-return-type */
380    public function setTimezone(DateTimeZone $timezone): DateTimeImmutable {}
381
382    /** @tentative-return-type */
383    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTimeImmutable {}
384
385    /** @tentative-return-type */
386    public function setDate(int $year, int $month, int $day): DateTimeImmutable {}
387
388    /** @tentative-return-type */
389    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTimeImmutable {}
390
391    /** @tentative-return-type */
392    public function setTimestamp(int $timestamp): DateTimeImmutable {}
393
394    /** @tentative-return-type */
395    public static function createFromMutable(DateTime $object): DateTimeImmutable {}
396
397    public static function createFromInterface(DateTimeInterface $object): DateTimeImmutable {}
398}
399
400class DateTimeZone
401{
402    public function __construct(string $timezone) {}
403
404    /**
405     * @tentative-return-type
406     * @alias timezone_name_get
407     */
408    public function getName(): string {}
409
410    /**
411     * @tentative-return-type
412     * @alias timezone_offset_get
413     */
414    public function getOffset(DateTimeInterface $datetime): int {}
415
416    /**
417     * @return array<int, array>|false
418     * @tentative-return-type
419     * @alias timezone_transitions_get
420     */
421    public function getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {}
422
423    /**
424     * @return array<string, float|string>|false
425     * @tentative-return-type
426     * @alias timezone_location_get
427     */
428    public function getLocation(): array|false {}
429
430    /**
431     * @return array<string, array>
432     * @tentative-return-type
433     * @alias timezone_abbreviations_list
434     */
435    public static function listAbbreviations(): array {}
436
437    /**
438     * @return array<int, string>
439     * @tentative-return-type
440     * @alias timezone_identifiers_list
441     */
442    public static function listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array {}
443
444    /** @tentative-return-type */
445    public function __wakeup(): void {}
446
447    /** @tentative-return-type */
448    public static function __set_state(array $array): DateTimeZone {}
449}
450
451class DateInterval
452{
453    public function __construct(string $duration) {}
454
455    /**
456     * @tentative-return-type
457     * @alias date_interval_create_from_date_string
458     */
459    public static function createFromDateString(string $datetime): DateInterval|false {}
460
461    /**
462     * @tentative-return-type
463     * @alias date_interval_format
464     */
465    public function format(string $format): string {}
466
467    /** @tentative-return-type */
468    public function __wakeup(): void {}
469
470    /** @tentative-return-type */
471    public static function __set_state(array $array): DateInterval {}
472}
473
474class DatePeriod implements IteratorAggregate
475{
476    /**
477     * @param DateTimeInterface|string $start
478     * @param DateInterval|int $interval
479     * @param DateTimeInterface|int $end
480     * @param int $options
481     */
482    public function __construct($start, $interval = UNKNOWN, $end = UNKNOWN, $options = UNKNOWN) {}
483
484    /** @tentative-return-type */
485    public function getStartDate(): DateTimeInterface {}
486
487    /** @tentative-return-type */
488    public function getEndDate(): ?DateTimeInterface {}
489
490    /** @tentative-return-type */
491    public function getDateInterval(): DateInterval {}
492
493    /** @tentative-return-type */
494    public function getRecurrences(): ?int {}
495
496    /** @tentative-return-type */
497    public function __wakeup(): void {}
498
499    /** @tentative-return-type */
500    public static function __set_state(array $array): DatePeriod {}
501
502    public function getIterator(): Iterator {}
503}
504