xref: /PHP-8.2/ext/date/php_date.stub.php (revision 6ae86c23)
1<?php
2
3/** @generate-class-entries */
4
5/**
6 * @var string
7 * @cvalue DATE_FORMAT_RFC3339
8 */
9const DATE_ATOM = "Y-m-d\\TH:i:sP";
10
11/**
12 * @var string
13 * @cvalue DATE_FORMAT_COOKIE
14 */
15const DATE_COOKIE = "l, d-M-Y H:i:s T";
16
17/**
18 * @var string
19 * @cvalue DATE_FORMAT_ISO8601
20 */
21const DATE_ISO8601 = "Y-m-d\\TH:i:sO";
22
23/**
24 * @var string
25 * @cvalue DATE_FORMAT_ISO8601_EXPANDED
26 */
27const DATE_ISO8601_EXPANDED = "X-m-d\\TH:i:sP";
28
29/**
30 * @var string
31 * @cvalue DATE_FORMAT_RFC822
32 */
33const DATE_RFC822 = "D, d M y H:i:s O";
34
35/**
36 * @var string
37 * @cvalue DATE_FORMAT_RFC850
38 */
39const DATE_RFC850 = "l, d-M-y H:i:s T";
40
41/**
42 * @var string
43 * @cvalue DATE_FORMAT_RFC1036
44 */
45const DATE_RFC1036 = "D, d M y H:i:s O";
46
47/**
48 * @var string
49 * @cvalue DATE_FORMAT_RFC1123
50 */
51const DATE_RFC1123 = "D, d M Y H:i:s O";
52
53/**
54 * @var string
55 * @cvalue DATE_FORMAT_RFC7231
56 */
57const DATE_RFC7231 = "D, d M Y H:i:s \\G\\M\\T";
58
59/**
60 * @var string
61 * @cvalue DATE_FORMAT_RFC2822
62 */
63const DATE_RFC2822 = "D, d M Y H:i:s O";
64
65/**
66 * @var string
67 * @cvalue DATE_FORMAT_RFC3339
68 */
69const DATE_RFC3339 = "Y-m-d\\TH:i:sP";
70
71/**
72 * @var string
73 * @cvalue DATE_FORMAT_RFC3339_EXTENDED
74 */
75const DATE_RFC3339_EXTENDED = "Y-m-d\\TH:i:s.vP";
76
77/** @var string */
78const DATE_RSS = DATE_RFC1123;
79
80/** @var string */
81const DATE_W3C = DATE_RFC3339;
82
83/**
84 * @var int
85 * @cvalue SUNFUNCS_RET_TIMESTAMP
86 */
87const SUNFUNCS_RET_TIMESTAMP = UNKNOWN;
88
89/**
90 * @var int
91 * @cvalue SUNFUNCS_RET_STRING
92 */
93const SUNFUNCS_RET_STRING = UNKNOWN;
94
95/**
96 * @var int
97 * @cvalue SUNFUNCS_RET_DOUBLE
98 */
99const SUNFUNCS_RET_DOUBLE = UNKNOWN;
100
101function strtotime(string $datetime, ?int $baseTimestamp = null): int|false {}
102
103/** @refcount 1 */
104function date(string $format, ?int $timestamp = null): string {}
105
106function idate(string $format, ?int $timestamp = null): int|false {}
107
108/** @refcount 1 */
109function gmdate(string $format, ?int $timestamp = null): string {}
110
111function mktime(
112    int $hour, ?int $minute = null, ?int $second = null,
113    ?int $month = null, ?int $day = null, ?int $year = null): int|false {}
114
115function gmmktime(
116    int $hour, ?int $minute = null, ?int $second = null,
117    ?int $month = null, ?int $day = null, ?int $year = null): int|false {}
118
119function checkdate(int $month, int $day, int $year): bool {}
120
121/**
122 * @refcount 1
123 * @deprecated
124 */
125function strftime(string $format, ?int $timestamp = null): string|false {}
126
127/**
128 * @refcount 1
129 * @deprecated
130 */
131function gmstrftime(string $format, ?int $timestamp = null): string|false {}
132
133function time(): int {}
134
135/**
136 * @return array<int|string, int>
137 * @refcount 1
138 */
139function localtime(?int $timestamp = null, bool $associative = false): array {}
140
141/**
142 * @return array<int|string, int|string>
143 * @refcount 1
144 */
145function getdate(?int $timestamp = null): array {}
146
147/** @refcount 1 */
148function date_create(string $datetime = "now", ?DateTimeZone $timezone = null): DateTime|false {}
149
150/** @refcount 1 */
151function date_create_immutable(
152    string $datetime = "now", ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
153
154/** @refcount 1 */
155function date_create_from_format(
156    string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false {}
157
158/** @refcount 1 */
159function date_create_immutable_from_format(
160    string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
161
162/**
163 * @return array<string, mixed>
164 * @refcount 1
165 */
166function date_parse(string $datetime): array {}
167
168/**
169 * @return array<string, mixed>
170 * @refcount 1
171 */
172function date_parse_from_format(string $format, string $datetime): array {}
173
174/**
175 * @return array<string, int|array>|false
176 * @refcount 1
177 */
178function date_get_last_errors(): array|false {}
179
180/** @refcount 1 */
181function date_format(DateTimeInterface $object, string $format): string {}
182
183function date_modify(DateTime $object, string $modifier): DateTime|false {}
184
185function date_add(DateTime $object, DateInterval $interval): DateTime {}
186
187function date_sub(DateTime $object, DateInterval $interval): DateTime {}
188
189/** @refcount 1 */
190function date_timezone_get(DateTimeInterface $object): DateTimeZone|false {}
191
192function date_timezone_set(DateTime $object, DateTimeZone $timezone): DateTime {}
193
194function date_offset_get(DateTimeInterface $object): int {}
195
196/** @refcount 1 */
197function date_diff(
198    DateTimeInterface $baseObject, DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
199
200function date_time_set(
201    DateTime $object, int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
202
203function date_date_set(DateTime $object, int $year, int $month, int $day): DateTime {}
204
205function date_isodate_set(DateTime $object, int $year, int $week, int $dayOfWeek = 1): DateTime {}
206
207function date_timestamp_set(DateTime $object, int $timestamp): DateTime {}
208
209function date_timestamp_get(DateTimeInterface $object): int {}
210
211/** @refcount 1 */
212function timezone_open(string $timezone): DateTimeZone|false {}
213
214/** @refcount 1 */
215function timezone_name_get(DateTimeZone $object): string {}
216
217/** @refcount 1 */
218function timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string|false {}
219
220function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime): int {}
221
222/**
223 * @return array<int, array>|false
224 * @refcount 1
225 */
226function timezone_transitions_get(
227    DateTimeZone $object, int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {}
228
229/**
230 * @return array<string, float|string>|false
231 * @refcount 1
232 */
233function timezone_location_get(DateTimeZone $object): array|false {}
234
235/**
236 * @return array<int, string>
237 * @refcount 1
238 */
239function timezone_identifiers_list(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array {}
240
241/**
242 * @return array<string, array>
243 * @refcount 1
244 */
245function timezone_abbreviations_list(): array {}
246
247/** @refcount 1 */
248function timezone_version_get(): string {}
249
250/** @refcount 1 */
251function date_interval_create_from_date_string(string $datetime): DateInterval|false {}
252
253/** @refcount 1 */
254function date_interval_format(DateInterval $object, string $format): string {}
255
256function date_default_timezone_set(string $timezoneId): bool {}
257
258/** @refcount 1 */
259function date_default_timezone_get(): string {}
260
261/**
262 * @refcount 1
263 * @deprecated
264 */
265function date_sunrise(
266    int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
267    ?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
268    ?float $utcOffset = null): string|int|float|false {}
269
270/**
271 * @refcount 1
272 * @deprecated
273 */
274function date_sunset(
275    int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
276    ?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
277    ?float $utcOffset = null): string|int|float|false {}
278
279/**
280 * @return array<string, bool|int>
281 * @refcount 1
282 */
283function date_sun_info(int $timestamp, float $latitude, float $longitude): array {}
284
285interface DateTimeInterface
286{
287    /** @var string */
288    public const ATOM = DATE_ATOM;
289    /** @var string */
290    public const COOKIE = DATE_COOKIE;
291    /** @var string */
292    public const ISO8601 = DATE_ISO8601;
293    /** @var string */
294    public const ISO8601_EXPANDED = DATE_ISO8601_EXPANDED;
295    /** @var string */
296    public const RFC822 = DATE_RFC822;
297    /** @var string */
298    public const RFC850 = DATE_RFC850;
299    /** @var string */
300    public const RFC1036 = DATE_RFC1036;
301    /** @var string */
302    public const RFC1123 = DATE_RFC1123;
303    /** @var string */
304    public const RFC7231 = DATE_RFC7231;
305    /** @var string */
306    public const RFC2822 = DATE_RFC2822;
307    /** @var string */
308    public const RFC3339 = DATE_RFC3339;
309    /** @var string */
310    public const RFC3339_EXTENDED = DATE_RFC3339_EXTENDED;
311    /** @var string */
312    public const RSS = DATE_RSS;
313    /** @var string */
314    public const W3C = DATE_W3C;
315
316    /** @tentative-return-type */
317    public function format(string $format): string;
318
319    /** @tentative-return-type */
320    public function getTimezone(): DateTimeZone|false;
321
322    /** @tentative-return-type */
323    public function getOffset(): int;
324
325    /** @tentative-return-type */
326    public function getTimestamp(): int;
327
328    /** @tentative-return-type */
329    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval;
330
331    /** @tentative-return-type */
332    public function __wakeup(): void;
333
334    public function __serialize(): array;
335
336    public function __unserialize(array $data): void;
337}
338
339class DateTime implements DateTimeInterface
340{
341    public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
342
343    public function __serialize(): array {}
344
345    public function __unserialize(array $data): void {}
346
347    /** @tentative-return-type */
348    public function __wakeup(): void {}
349
350    /** @tentative-return-type */
351    public static function __set_state(array $array): DateTime {}
352
353    /** @tentative-return-type */
354    public static function createFromImmutable(DateTimeImmutable $object): static {}
355
356    /** @return static */
357    public static function createFromInterface(DateTimeInterface $object): DateTime {} // TODO return type should be static
358
359    /**
360     * @tentative-return-type
361     * @alias date_create_from_format
362     */
363    public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false {}
364
365    /**
366     * @return array<string, int|array>|false
367     * @tentative-return-type
368     * @alias date_get_last_errors
369     */
370    public static function getLastErrors(): array|false {}
371
372    /**
373     * @tentative-return-type
374     * @alias date_format
375     */
376    public function format(string $format): string {}
377
378    /**
379     * @tentative-return-type
380     * @alias date_modify
381     */
382    public function modify(string $modifier): DateTime|false {}
383
384    /**
385     * @tentative-return-type
386     * @alias date_add
387     */
388    public function add(DateInterval $interval): DateTime {}
389
390    /**
391     * @tentative-return-type
392     * @alias date_sub
393     */
394    public function sub(DateInterval $interval): DateTime {}
395
396    /**
397     * @tentative-return-type
398     * @alias date_timezone_get
399     */
400    public function getTimezone(): DateTimeZone|false {}
401
402    /**
403     * @tentative-return-type
404     * @alias date_timezone_set
405     */
406    public function setTimezone(DateTimeZone $timezone): DateTime {}
407
408    /**
409     * @tentative-return-type
410     * @alias date_offset_get
411     */
412    public function getOffset(): int {}
413
414    /**
415     * @tentative-return-type
416     * @alias date_time_set
417     */
418    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
419
420    /**
421     * @tentative-return-type
422     * @alias date_date_set
423     */
424    public function setDate(int $year, int $month, int $day): DateTime {}
425
426    /**
427     * @tentative-return-type
428     * @alias date_isodate_set
429     */
430    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTime {}
431
432    /**
433     * @tentative-return-type
434     * @alias date_timestamp_set
435     */
436    public function setTimestamp(int $timestamp): DateTime {}
437
438    /**
439     * @tentative-return-type
440     * @alias date_timestamp_get
441     */
442    public function getTimestamp(): int {}
443
444    /**
445     * @tentative-return-type
446     * @alias date_diff
447     */
448    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
449}
450
451class DateTimeImmutable implements DateTimeInterface
452{
453    public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
454
455    public function __serialize(): array {}
456
457    public function __unserialize(array $data): void {}
458
459    /** @tentative-return-type */
460    public function __wakeup(): void {}
461
462    /** @tentative-return-type */
463    public static function __set_state(array $array): DateTimeImmutable {}
464
465    /**
466     * @tentative-return-type
467     * @alias date_create_immutable_from_format
468     */
469    public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
470
471    /**
472     * @return array<string, int|array>|false
473     * @tentative-return-type
474     * @alias date_get_last_errors
475     */
476    public static function getLastErrors(): array|false {}
477
478    /**
479     * @tentative-return-type
480     * @alias date_format
481     */
482    public function format(string $format): string {}
483
484    /**
485     * @tentative-return-type
486     * @alias date_timezone_get
487     */
488    public function getTimezone(): DateTimeZone|false {}
489
490    /**
491     * @tentative-return-type
492     * @alias date_offset_get
493     */
494    public function getOffset(): int {}
495
496    /**
497     * @tentative-return-type
498     * @alias date_timestamp_get
499     */
500    public function getTimestamp(): int {}
501
502    /**
503     * @tentative-return-type
504     * @alias date_diff
505     */
506    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
507
508    /** @tentative-return-type */
509    public function modify(string $modifier): DateTimeImmutable|false {}
510
511    /** @tentative-return-type */
512    public function add(DateInterval $interval): DateTimeImmutable {}
513
514    /** @tentative-return-type */
515    public function sub(DateInterval $interval): DateTimeImmutable {}
516
517    /** @tentative-return-type */
518    public function setTimezone(DateTimeZone $timezone): DateTimeImmutable {}
519
520    /** @tentative-return-type */
521    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTimeImmutable {}
522
523    /** @tentative-return-type */
524    public function setDate(int $year, int $month, int $day): DateTimeImmutable {}
525
526    /** @tentative-return-type */
527    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTimeImmutable {}
528
529    /** @tentative-return-type */
530    public function setTimestamp(int $timestamp): DateTimeImmutable {}
531
532    /** @tentative-return-type */
533    public static function createFromMutable(DateTime $object): static {}
534
535    /** @return static */
536    public static function createFromInterface(DateTimeInterface $object): DateTimeImmutable {} // TODO return type should be static
537}
538
539class DateTimeZone
540{
541    /**
542     * @var int
543     * @cvalue PHP_DATE_TIMEZONE_GROUP_AFRICA
544     */
545    public const AFRICA = UNKNOWN;
546    /**
547     * @var int
548     * @cvalue PHP_DATE_TIMEZONE_GROUP_AMERICA
549     */
550    public const AMERICA = UNKNOWN;
551    /**
552     * @var int
553     * @cvalue PHP_DATE_TIMEZONE_GROUP_ANTARCTICA
554     */
555    public const ANTARCTICA = UNKNOWN;
556    /**
557     * @var int
558     * @cvalue PHP_DATE_TIMEZONE_GROUP_ARCTIC
559     */
560    public const ARCTIC = UNKNOWN;
561    /**
562     * @var int
563     * @cvalue PHP_DATE_TIMEZONE_GROUP_ASIA
564     */
565    public const ASIA = UNKNOWN;
566    /**
567     * @var int
568     * @cvalue PHP_DATE_TIMEZONE_GROUP_ATLANTIC
569     */
570    public const ATLANTIC = UNKNOWN;
571    /**
572     * @var int
573     * @cvalue PHP_DATE_TIMEZONE_GROUP_AUSTRALIA
574     */
575    public const AUSTRALIA = UNKNOWN;
576    /**
577     * @var int
578     * @cvalue PHP_DATE_TIMEZONE_GROUP_EUROPE
579     */
580    public const EUROPE = UNKNOWN;
581    /**
582     * @var int
583     * @cvalue PHP_DATE_TIMEZONE_GROUP_INDIAN
584     */
585    public const INDIAN = UNKNOWN;
586    /**
587     * @var int
588     * @cvalue PHP_DATE_TIMEZONE_GROUP_PACIFIC
589     */
590    public const PACIFIC = UNKNOWN;
591    /**
592     * @var int
593     * @cvalue PHP_DATE_TIMEZONE_GROUP_UTC
594     */
595    public const UTC = UNKNOWN;
596    /**
597     * @var int
598     * @cvalue PHP_DATE_TIMEZONE_GROUP_ALL
599     */
600    public const ALL = UNKNOWN;
601    /**
602     * @var int
603     * @cvalue PHP_DATE_TIMEZONE_GROUP_ALL_W_BC
604     */
605    public const ALL_WITH_BC = UNKNOWN;
606    /**
607     * @var int
608     * @cvalue PHP_DATE_TIMEZONE_PER_COUNTRY
609     */
610    public const PER_COUNTRY = UNKNOWN;
611
612    public function __construct(string $timezone) {}
613
614    /**
615     * @tentative-return-type
616     * @alias timezone_name_get
617     */
618    public function getName(): string {}
619
620    /**
621     * @tentative-return-type
622     * @alias timezone_offset_get
623     */
624    public function getOffset(DateTimeInterface $datetime): int {}
625
626    /**
627     * @return array<int, array>|false
628     * @tentative-return-type
629     * @alias timezone_transitions_get
630     */
631    public function getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {}
632
633    /**
634     * @return array<string, float|string>|false
635     * @tentative-return-type
636     * @alias timezone_location_get
637     */
638    public function getLocation(): array|false {}
639
640    /**
641     * @return array<string, array>
642     * @tentative-return-type
643     * @alias timezone_abbreviations_list
644     */
645    public static function listAbbreviations(): array {}
646
647    /**
648     * @return array<int, string>
649     * @tentative-return-type
650     * @alias timezone_identifiers_list
651     */
652    public static function listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array {}
653
654    public function __serialize(): array {}
655
656    public function __unserialize(array $data): void {}
657
658    /** @tentative-return-type */
659    public function __wakeup(): void {}
660
661    /** @tentative-return-type */
662    public static function __set_state(array $array): DateTimeZone {}
663}
664
665class DateInterval
666{
667    public function __construct(string $duration) {}
668
669    /**
670     * @tentative-return-type
671     * @alias date_interval_create_from_date_string
672     */
673    public static function createFromDateString(string $datetime): DateInterval|false {}
674
675    /**
676     * @tentative-return-type
677     * @alias date_interval_format
678     */
679    public function format(string $format): string {}
680
681    public function __serialize(): array;
682
683    public function __unserialize(array $data): void;
684
685    /** @tentative-return-type */
686    public function __wakeup(): void {}
687
688    /** @tentative-return-type */
689    public static function __set_state(array $array): DateInterval {}
690}
691
692class DatePeriod implements IteratorAggregate
693{
694    /**
695     * @var int
696     * @cvalue PHP_DATE_PERIOD_EXCLUDE_START_DATE
697     */
698    public const EXCLUDE_START_DATE = UNKNOWN;
699    /**
700     * @var int
701     * @cvalue PHP_DATE_PERIOD_INCLUDE_END_DATE
702     */
703    public const INCLUDE_END_DATE = UNKNOWN;
704
705    /** @readonly */
706    public ?DateTimeInterface $start;
707    /** @readonly */
708    public ?DateTimeInterface $current;
709    /** @readonly */
710    public ?DateTimeInterface $end;
711    /** @readonly */
712    public ?DateInterval $interval;
713    /** @readonly */
714    public int $recurrences;
715    /** @readonly */
716    public bool $include_start_date;
717    /** @readonly */
718    public bool $include_end_date;
719
720    /**
721     * @param DateTimeInterface|string $start
722     * @param DateInterval|int $interval
723     * @param DateTimeInterface|int $end
724     * @param int $options
725     */
726    public function __construct($start, $interval = UNKNOWN, $end = UNKNOWN, $options = UNKNOWN) {}
727
728    /** @tentative-return-type */
729    public function getStartDate(): DateTimeInterface {}
730
731    /** @tentative-return-type */
732    public function getEndDate(): ?DateTimeInterface {}
733
734    /** @tentative-return-type */
735    public function getDateInterval(): DateInterval {}
736
737    /** @tentative-return-type */
738    public function getRecurrences(): ?int {}
739
740    public function __serialize(): array;
741
742    public function __unserialize(array $data): void;
743
744    /** @tentative-return-type */
745    public function __wakeup(): void {}
746
747    /** @tentative-return-type */
748    public static function __set_state(array $array): DatePeriod {}
749
750    public function getIterator(): Iterator {}
751}
752