xref: /PHP-8.2/ext/date/php_date.stub.php (revision 0016b308)
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    /** @tentative-return-type */
366    public static function createFromTimestamp(int|float $timestamp): static {}
367
368    /**
369     * @return array<string, int|array>|false
370     * @tentative-return-type
371     * @alias date_get_last_errors
372     */
373    public static function getLastErrors(): array|false {}
374
375    /**
376     * @tentative-return-type
377     * @alias date_format
378     */
379    public function format(string $format): string {}
380
381    /**
382     * @tentative-return-type
383     */
384    public function modify(string $modifier): DateTime|false {}
385
386    /**
387     * @tentative-return-type
388     * @alias date_add
389     */
390    public function add(DateInterval $interval): DateTime {}
391
392    /**
393     * @tentative-return-type
394     */
395    public function sub(DateInterval $interval): DateTime {}
396
397    /**
398     * @tentative-return-type
399     * @alias date_timezone_get
400     */
401    public function getTimezone(): DateTimeZone|false {}
402
403    /**
404     * @tentative-return-type
405     * @alias date_timezone_set
406     */
407    public function setTimezone(DateTimeZone $timezone): DateTime {}
408
409    /**
410     * @tentative-return-type
411     * @alias date_offset_get
412     */
413    public function getOffset(): int {}
414
415    /** @tentative-return-type */
416    public function getMicroseconds(): int {}
417
418    /**
419     * @tentative-return-type
420     * @alias date_time_set
421     */
422    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
423
424    /**
425     * @tentative-return-type
426     * @alias date_date_set
427     */
428    public function setDate(int $year, int $month, int $day): DateTime {}
429
430    /**
431     * @tentative-return-type
432     * @alias date_isodate_set
433     */
434    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTime {}
435
436    /**
437     * @tentative-return-type
438     * @alias date_timestamp_set
439     */
440    public function setTimestamp(int $timestamp): DateTime {}
441
442    /** @tentative-return-type */
443    public function setMicroseconds(int $microseconds): static {}
444
445    /**
446     * @tentative-return-type
447     * @alias date_timestamp_get
448     */
449    public function getTimestamp(): int {}
450
451    /**
452     * @tentative-return-type
453     * @alias date_diff
454     */
455    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
456}
457
458class DateTimeImmutable implements DateTimeInterface
459{
460    public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
461
462    public function __serialize(): array {}
463
464    public function __unserialize(array $data): void {}
465
466    /** @tentative-return-type */
467    public function __wakeup(): void {}
468
469    /** @tentative-return-type */
470    public static function __set_state(array $array): DateTimeImmutable {}
471
472    /**
473     * @tentative-return-type
474     * @alias date_create_immutable_from_format
475     */
476    public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
477
478    /** @tentative-return-type */
479    public static function createFromTimestamp(int|float $timestamp): static {}
480
481    /**
482     * @return array<string, int|array>|false
483     * @tentative-return-type
484     * @alias date_get_last_errors
485     */
486    public static function getLastErrors(): array|false {}
487
488    /**
489     * @tentative-return-type
490     * @alias date_format
491     */
492    public function format(string $format): string {}
493
494    /**
495     * @tentative-return-type
496     * @alias date_timezone_get
497     */
498    public function getTimezone(): DateTimeZone|false {}
499
500    /**
501     * @tentative-return-type
502     * @alias date_offset_get
503     */
504    public function getOffset(): int {}
505
506    /**
507     * @tentative-return-type
508     * @alias date_timestamp_get
509     */
510    public function getTimestamp(): int {}
511
512    /**
513     * @alias DateTime::getMicroseconds
514     * @tentative-return-type
515     */
516    public function getMicroseconds(): int {}
517
518    /**
519     * @tentative-return-type
520     * @alias date_diff
521     */
522    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
523
524    /** @tentative-return-type */
525    public function modify(string $modifier): DateTimeImmutable|false {}
526
527    /** @tentative-return-type */
528    public function add(DateInterval $interval): DateTimeImmutable {}
529
530    /** @tentative-return-type */
531    public function sub(DateInterval $interval): DateTimeImmutable {}
532
533    /** @tentative-return-type */
534    public function setTimezone(DateTimeZone $timezone): DateTimeImmutable {}
535
536    /** @tentative-return-type */
537    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTimeImmutable {}
538
539    /** @tentative-return-type */
540    public function setDate(int $year, int $month, int $day): DateTimeImmutable {}
541
542    /** @tentative-return-type */
543    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTimeImmutable {}
544
545    /** @tentative-return-type */
546    public function setTimestamp(int $timestamp): DateTimeImmutable {}
547
548    /** @tentative-return-type */
549    public function setMicroseconds(int $microseconds): static {}
550
551    /** @tentative-return-type */
552    public static function createFromMutable(DateTime $object): static {}
553
554    /** @return static */
555    public static function createFromInterface(DateTimeInterface $object): DateTimeImmutable {} // TODO return type should be static
556}
557
558class DateTimeZone
559{
560    /**
561     * @var int
562     * @cvalue PHP_DATE_TIMEZONE_GROUP_AFRICA
563     */
564    public const AFRICA = UNKNOWN;
565    /**
566     * @var int
567     * @cvalue PHP_DATE_TIMEZONE_GROUP_AMERICA
568     */
569    public const AMERICA = UNKNOWN;
570    /**
571     * @var int
572     * @cvalue PHP_DATE_TIMEZONE_GROUP_ANTARCTICA
573     */
574    public const ANTARCTICA = UNKNOWN;
575    /**
576     * @var int
577     * @cvalue PHP_DATE_TIMEZONE_GROUP_ARCTIC
578     */
579    public const ARCTIC = UNKNOWN;
580    /**
581     * @var int
582     * @cvalue PHP_DATE_TIMEZONE_GROUP_ASIA
583     */
584    public const ASIA = UNKNOWN;
585    /**
586     * @var int
587     * @cvalue PHP_DATE_TIMEZONE_GROUP_ATLANTIC
588     */
589    public const ATLANTIC = UNKNOWN;
590    /**
591     * @var int
592     * @cvalue PHP_DATE_TIMEZONE_GROUP_AUSTRALIA
593     */
594    public const AUSTRALIA = UNKNOWN;
595    /**
596     * @var int
597     * @cvalue PHP_DATE_TIMEZONE_GROUP_EUROPE
598     */
599    public const EUROPE = UNKNOWN;
600    /**
601     * @var int
602     * @cvalue PHP_DATE_TIMEZONE_GROUP_INDIAN
603     */
604    public const INDIAN = UNKNOWN;
605    /**
606     * @var int
607     * @cvalue PHP_DATE_TIMEZONE_GROUP_PACIFIC
608     */
609    public const PACIFIC = UNKNOWN;
610    /**
611     * @var int
612     * @cvalue PHP_DATE_TIMEZONE_GROUP_UTC
613     */
614    public const UTC = UNKNOWN;
615    /**
616     * @var int
617     * @cvalue PHP_DATE_TIMEZONE_GROUP_ALL
618     */
619    public const ALL = UNKNOWN;
620    /**
621     * @var int
622     * @cvalue PHP_DATE_TIMEZONE_GROUP_ALL_W_BC
623     */
624    public const ALL_WITH_BC = UNKNOWN;
625    /**
626     * @var int
627     * @cvalue PHP_DATE_TIMEZONE_PER_COUNTRY
628     */
629    public const PER_COUNTRY = UNKNOWN;
630
631    public function __construct(string $timezone) {}
632
633    /**
634     * @tentative-return-type
635     * @alias timezone_name_get
636     */
637    public function getName(): string {}
638
639    /**
640     * @tentative-return-type
641     * @alias timezone_offset_get
642     */
643    public function getOffset(DateTimeInterface $datetime): int {}
644
645    /**
646     * @return array<int, array>|false
647     * @tentative-return-type
648     * @alias timezone_transitions_get
649     */
650    public function getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {}
651
652    /**
653     * @return array<string, float|string>|false
654     * @tentative-return-type
655     * @alias timezone_location_get
656     */
657    public function getLocation(): array|false {}
658
659    /**
660     * @return array<string, array>
661     * @tentative-return-type
662     * @alias timezone_abbreviations_list
663     */
664    public static function listAbbreviations(): array {}
665
666    /**
667     * @return array<int, string>
668     * @tentative-return-type
669     * @alias timezone_identifiers_list
670     */
671    public static function listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array {}
672
673    public function __serialize(): array {}
674
675    public function __unserialize(array $data): void {}
676
677    /** @tentative-return-type */
678    public function __wakeup(): void {}
679
680    /** @tentative-return-type */
681    public static function __set_state(array $array): DateTimeZone {}
682}
683
684class DateInterval
685{
686    public function __construct(string $duration) {}
687
688    /**
689     * @tentative-return-type
690     */
691    public static function createFromDateString(string $datetime): DateInterval|false {}
692
693    /**
694     * @tentative-return-type
695     * @alias date_interval_format
696     */
697    public function format(string $format): string {}
698
699    public function __serialize(): array;
700
701    public function __unserialize(array $data): void;
702
703    /** @tentative-return-type */
704    public function __wakeup(): void {}
705
706    /** @tentative-return-type */
707    public static function __set_state(array $array): DateInterval {}
708}
709
710class DatePeriod implements IteratorAggregate
711{
712    /**
713     * @var int
714     * @cvalue PHP_DATE_PERIOD_EXCLUDE_START_DATE
715     */
716    public const EXCLUDE_START_DATE = UNKNOWN;
717    /**
718     * @var int
719     * @cvalue PHP_DATE_PERIOD_INCLUDE_END_DATE
720     */
721    public const INCLUDE_END_DATE = UNKNOWN;
722
723    /** @readonly */
724    public ?DateTimeInterface $start;
725    /** @readonly */
726    public ?DateTimeInterface $current;
727    /** @readonly */
728    public ?DateTimeInterface $end;
729    /** @readonly */
730    public ?DateInterval $interval;
731    /** @readonly */
732    public int $recurrences;
733    /** @readonly */
734    public bool $include_start_date;
735    /** @readonly */
736    public bool $include_end_date;
737
738    public static function createFromISO8601String(string $specification, int $options = 0): static {}
739
740    /**
741     * @param DateTimeInterface|string $start
742     * @param DateInterval|int $interval
743     * @param DateTimeInterface|int $end
744     * @param int $options
745     */
746    public function __construct($start, $interval = UNKNOWN, $end = UNKNOWN, $options = UNKNOWN) {}
747
748    /** @tentative-return-type */
749    public function getStartDate(): DateTimeInterface {}
750
751    /** @tentative-return-type */
752    public function getEndDate(): ?DateTimeInterface {}
753
754    /** @tentative-return-type */
755    public function getDateInterval(): DateInterval {}
756
757    /** @tentative-return-type */
758    public function getRecurrences(): ?int {}
759
760    public function __serialize(): array;
761
762    public function __unserialize(array $data): void;
763
764    /** @tentative-return-type */
765    public function __wakeup(): void {}
766
767    /** @tentative-return-type */
768    public static function __set_state(array $array): DatePeriod {}
769
770    public function getIterator(): Iterator {}
771}
772
773/**
774 * @strict-properties
775 */
776class DateError extends Error
777{
778}
779
780/**
781 * @strict-properties
782 */
783class DateObjectError extends DateError
784{
785}
786
787/**
788 * @strict-properties
789 */
790class DateRangeError extends DateError
791{
792}
793
794/**
795 * @strict-properties
796 */
797class DateException extends Exception
798{
799}
800
801/**
802 * @strict-properties
803 */
804class DateInvalidTimeZoneException extends DateException
805{
806}
807
808/**
809 * @strict-properties
810 */
811class DateInvalidOperationException extends DateException
812{
813}
814
815/**
816 * @strict-properties
817 */
818class DateMalformedStringException extends DateException
819{
820}
821
822/**
823 * @strict-properties
824 */
825class DateMalformedIntervalStringException extends DateException
826{
827}
828
829/**
830 * @strict-properties
831 */
832class DateMalformedPeriodStringException extends DateException
833{
834}
835