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