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