massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / datetime.pyi
1 import sys
2 from time import struct_time
3 from typing import ClassVar, NamedTuple, NoReturn, SupportsAbs, Type, TypeVar, overload
4 from typing_extensions import final
5
6 _S = TypeVar("_S")
7 _D = TypeVar("_D", bound=date)
8
9 MINYEAR: int
10 MAXYEAR: int
11
12 class tzinfo:
13     def tzname(self, __dt: datetime | None) -> str | None: ...
14     def utcoffset(self, __dt: datetime | None) -> timedelta | None: ...
15     def dst(self, __dt: datetime | None) -> timedelta | None: ...
16     def fromutc(self, __dt: datetime) -> datetime: ...
17
18 # Alias required to avoid name conflicts with date(time).tzinfo.
19 _tzinfo = tzinfo
20
21 @final
22 class timezone(tzinfo):
23     utc: ClassVar[timezone]
24     min: ClassVar[timezone]
25     max: ClassVar[timezone]
26     def __init__(self, offset: timedelta, name: str = ...) -> None: ...
27     def __hash__(self) -> int: ...
28
29 if sys.version_info >= (3, 9):
30     class _IsoCalendarDate(NamedTuple):
31         year: int
32         week: int
33         weekday: int
34
35 class date:
36     min: ClassVar[date]
37     max: ClassVar[date]
38     resolution: ClassVar[timedelta]
39     def __new__(cls: Type[_S], year: int, month: int, day: int) -> _S: ...
40     @classmethod
41     def fromtimestamp(cls: Type[_S], __timestamp: float) -> _S: ...
42     @classmethod
43     def today(cls: Type[_S]) -> _S: ...
44     @classmethod
45     def fromordinal(cls: Type[_S], __n: int) -> _S: ...
46     if sys.version_info >= (3, 7):
47         @classmethod
48         def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ...
49     if sys.version_info >= (3, 8):
50         @classmethod
51         def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ...
52     @property
53     def year(self) -> int: ...
54     @property
55     def month(self) -> int: ...
56     @property
57     def day(self) -> int: ...
58     def ctime(self) -> str: ...
59     def strftime(self, fmt: str) -> str: ...
60     def __format__(self, __fmt: str) -> str: ...
61     def isoformat(self) -> str: ...
62     def timetuple(self) -> struct_time: ...
63     def toordinal(self) -> int: ...
64     def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ...
65     def __le__(self, __other: date) -> bool: ...
66     def __lt__(self, __other: date) -> bool: ...
67     def __ge__(self, __other: date) -> bool: ...
68     def __gt__(self, __other: date) -> bool: ...
69     if sys.version_info >= (3, 8):
70         def __add__(self: _S, __other: timedelta) -> _S: ...
71         def __radd__(self: _S, __other: timedelta) -> _S: ...
72         @overload
73         def __sub__(self: _D, __other: timedelta) -> _D: ...
74         @overload
75         def __sub__(self, __other: datetime) -> NoReturn: ...
76         @overload
77         def __sub__(self: _D, __other: _D) -> timedelta: ...
78     else:
79         # Prior to Python 3.8, arithmetic operations always returned `date`, even in subclasses
80         def __add__(self, __other: timedelta) -> date: ...
81         def __radd__(self, __other: timedelta) -> date: ...
82         @overload
83         def __sub__(self, __other: timedelta) -> date: ...
84         @overload
85         def __sub__(self, __other: datetime) -> NoReturn: ...
86         @overload
87         def __sub__(self, __other: date) -> timedelta: ...
88     def __hash__(self) -> int: ...
89     def weekday(self) -> int: ...
90     def isoweekday(self) -> int: ...
91     if sys.version_info >= (3, 9):
92         def isocalendar(self) -> _IsoCalendarDate: ...
93     else:
94         def isocalendar(self) -> tuple[int, int, int]: ...
95
96 class time:
97     min: ClassVar[time]
98     max: ClassVar[time]
99     resolution: ClassVar[timedelta]
100     def __new__(
101         cls: Type[_S],
102         hour: int = ...,
103         minute: int = ...,
104         second: int = ...,
105         microsecond: int = ...,
106         tzinfo: _tzinfo | None = ...,
107         *,
108         fold: int = ...,
109     ) -> _S: ...
110     @property
111     def hour(self) -> int: ...
112     @property
113     def minute(self) -> int: ...
114     @property
115     def second(self) -> int: ...
116     @property
117     def microsecond(self) -> int: ...
118     @property
119     def tzinfo(self) -> _tzinfo | None: ...
120     @property
121     def fold(self) -> int: ...
122     def __le__(self, __other: time) -> bool: ...
123     def __lt__(self, __other: time) -> bool: ...
124     def __ge__(self, __other: time) -> bool: ...
125     def __gt__(self, __other: time) -> bool: ...
126     def __hash__(self) -> int: ...
127     def isoformat(self, timespec: str = ...) -> str: ...
128     if sys.version_info >= (3, 7):
129         @classmethod
130         def fromisoformat(cls: Type[_S], __time_string: str) -> _S: ...
131     def strftime(self, fmt: str) -> str: ...
132     def __format__(self, __fmt: str) -> str: ...
133     def utcoffset(self) -> timedelta | None: ...
134     def tzname(self) -> str | None: ...
135     def dst(self) -> timedelta | None: ...
136     def replace(
137         self,
138         hour: int = ...,
139         minute: int = ...,
140         second: int = ...,
141         microsecond: int = ...,
142         tzinfo: _tzinfo | None = ...,
143         *,
144         fold: int = ...,
145     ) -> time: ...
146
147 _date = date
148 _time = time
149
150 class timedelta(SupportsAbs[timedelta]):
151     min: ClassVar[timedelta]
152     max: ClassVar[timedelta]
153     resolution: ClassVar[timedelta]
154     def __new__(
155         cls: Type[_S],
156         days: float = ...,
157         seconds: float = ...,
158         microseconds: float = ...,
159         milliseconds: float = ...,
160         minutes: float = ...,
161         hours: float = ...,
162         weeks: float = ...,
163     ) -> _S: ...
164     @property
165     def days(self) -> int: ...
166     @property
167     def seconds(self) -> int: ...
168     @property
169     def microseconds(self) -> int: ...
170     def total_seconds(self) -> float: ...
171     def __add__(self, __other: timedelta) -> timedelta: ...
172     def __radd__(self, __other: timedelta) -> timedelta: ...
173     def __sub__(self, __other: timedelta) -> timedelta: ...
174     def __rsub__(self, __other: timedelta) -> timedelta: ...
175     def __neg__(self) -> timedelta: ...
176     def __pos__(self) -> timedelta: ...
177     def __abs__(self) -> timedelta: ...
178     def __mul__(self, __other: float) -> timedelta: ...
179     def __rmul__(self, __other: float) -> timedelta: ...
180     @overload
181     def __floordiv__(self, __other: timedelta) -> int: ...
182     @overload
183     def __floordiv__(self, __other: int) -> timedelta: ...
184     @overload
185     def __truediv__(self, __other: timedelta) -> float: ...
186     @overload
187     def __truediv__(self, __other: float) -> timedelta: ...
188     def __mod__(self, __other: timedelta) -> timedelta: ...
189     def __divmod__(self, __other: timedelta) -> tuple[int, timedelta]: ...
190     def __le__(self, __other: timedelta) -> bool: ...
191     def __lt__(self, __other: timedelta) -> bool: ...
192     def __ge__(self, __other: timedelta) -> bool: ...
193     def __gt__(self, __other: timedelta) -> bool: ...
194     def __bool__(self) -> bool: ...
195     def __hash__(self) -> int: ...
196
197 class datetime(date):
198     min: ClassVar[datetime]
199     max: ClassVar[datetime]
200     resolution: ClassVar[timedelta]
201     def __new__(
202         cls: Type[_S],
203         year: int,
204         month: int,
205         day: int,
206         hour: int = ...,
207         minute: int = ...,
208         second: int = ...,
209         microsecond: int = ...,
210         tzinfo: _tzinfo | None = ...,
211         *,
212         fold: int = ...,
213     ) -> _S: ...
214     @property
215     def hour(self) -> int: ...
216     @property
217     def minute(self) -> int: ...
218     @property
219     def second(self) -> int: ...
220     @property
221     def microsecond(self) -> int: ...
222     @property
223     def tzinfo(self) -> _tzinfo | None: ...
224     @property
225     def fold(self) -> int: ...
226     # The first parameter in `fromtimestamp` is actually positional-or-keyword,
227     # but it is named "timestamp" in the C implementation and "t" in the Python implementation,
228     # so it is only truly *safe* to pass it as a positional argument.
229     @classmethod
230     def fromtimestamp(cls: Type[_S], __timestamp: float, tz: _tzinfo | None = ...) -> _S: ...
231     @classmethod
232     def utcfromtimestamp(cls: Type[_S], __t: float) -> _S: ...
233     if sys.version_info >= (3, 8):
234         @classmethod
235         def now(cls: Type[_S], tz: _tzinfo | None = ...) -> _S: ...
236     else:
237         @overload
238         @classmethod
239         def now(cls: Type[_S], tz: None = ...) -> _S: ...
240         @overload
241         @classmethod
242         def now(cls, tz: _tzinfo) -> datetime: ...
243     @classmethod
244     def utcnow(cls: Type[_S]) -> _S: ...
245     @classmethod
246     def combine(cls, date: _date, time: _time, tzinfo: _tzinfo | None = ...) -> datetime: ...
247     if sys.version_info >= (3, 7):
248         @classmethod
249         def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ...
250     def timestamp(self) -> float: ...
251     def utctimetuple(self) -> struct_time: ...
252     def date(self) -> _date: ...
253     def time(self) -> _time: ...
254     def timetz(self) -> _time: ...
255     def replace(
256         self,
257         year: int = ...,
258         month: int = ...,
259         day: int = ...,
260         hour: int = ...,
261         minute: int = ...,
262         second: int = ...,
263         microsecond: int = ...,
264         tzinfo: _tzinfo | None = ...,
265         *,
266         fold: int = ...,
267     ) -> datetime: ...
268     if sys.version_info >= (3, 8):
269         def astimezone(self: _S, tz: _tzinfo | None = ...) -> _S: ...
270     else:
271         def astimezone(self, tz: _tzinfo | None = ...) -> datetime: ...
272     def ctime(self) -> str: ...
273     def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
274     @classmethod
275     def strptime(cls, __date_string: str, __format: str) -> datetime: ...
276     def utcoffset(self) -> timedelta | None: ...
277     def tzname(self) -> str | None: ...
278     def dst(self) -> timedelta | None: ...
279     def __le__(self, __other: datetime) -> bool: ...  # type: ignore
280     def __lt__(self, __other: datetime) -> bool: ...  # type: ignore
281     def __ge__(self, __other: datetime) -> bool: ...  # type: ignore
282     def __gt__(self, __other: datetime) -> bool: ...  # type: ignore
283     if sys.version_info >= (3, 8):
284         @overload  # type: ignore[override]
285         def __sub__(self: _D, __other: timedelta) -> _D: ...
286         @overload
287         def __sub__(self: _D, __other: _D) -> timedelta: ...
288     else:
289         # Prior to Python 3.8, arithmetic operations always returned `datetime`, even in subclasses
290         def __add__(self, __other: timedelta) -> datetime: ...
291         def __radd__(self, __other: timedelta) -> datetime: ...
292         @overload  # type: ignore[override]
293         def __sub__(self, __other: datetime) -> timedelta: ...
294         @overload
295         def __sub__(self, __other: timedelta) -> datetime: ...
296     if sys.version_info >= (3, 9):
297         def isocalendar(self) -> _IsoCalendarDate: ...
298     else:
299         def isocalendar(self) -> tuple[int, int, int]: ...