2 from time import struct_time
3 from typing import ClassVar, NamedTuple, NoReturn, SupportsAbs, Type, TypeVar, overload
4 from typing_extensions import final
7 _D = TypeVar("_D", bound=date)
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: ...
18 # Alias required to avoid name conflicts with date(time).tzinfo.
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: ...
29 if sys.version_info >= (3, 9):
30 class _IsoCalendarDate(NamedTuple):
38 resolution: ClassVar[timedelta]
39 def __new__(cls: Type[_S], year: int, month: int, day: int) -> _S: ...
41 def fromtimestamp(cls: Type[_S], __timestamp: float) -> _S: ...
43 def today(cls: Type[_S]) -> _S: ...
45 def fromordinal(cls: Type[_S], __n: int) -> _S: ...
46 if sys.version_info >= (3, 7):
48 def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ...
49 if sys.version_info >= (3, 8):
51 def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ...
53 def year(self) -> int: ...
55 def month(self) -> int: ...
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: ...
73 def __sub__(self: _D, __other: timedelta) -> _D: ...
75 def __sub__(self, __other: datetime) -> NoReturn: ...
77 def __sub__(self: _D, __other: _D) -> timedelta: ...
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: ...
83 def __sub__(self, __other: timedelta) -> date: ...
85 def __sub__(self, __other: datetime) -> NoReturn: ...
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: ...
94 def isocalendar(self) -> tuple[int, int, int]: ...
99 resolution: ClassVar[timedelta]
105 microsecond: int = ...,
106 tzinfo: _tzinfo | None = ...,
111 def hour(self) -> int: ...
113 def minute(self) -> int: ...
115 def second(self) -> int: ...
117 def microsecond(self) -> int: ...
119 def tzinfo(self) -> _tzinfo | None: ...
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):
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: ...
141 microsecond: int = ...,
142 tzinfo: _tzinfo | None = ...,
150 class timedelta(SupportsAbs[timedelta]):
151 min: ClassVar[timedelta]
152 max: ClassVar[timedelta]
153 resolution: ClassVar[timedelta]
157 seconds: float = ...,
158 microseconds: float = ...,
159 milliseconds: float = ...,
160 minutes: float = ...,
165 def days(self) -> int: ...
167 def seconds(self) -> int: ...
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: ...
181 def __floordiv__(self, __other: timedelta) -> int: ...
183 def __floordiv__(self, __other: int) -> timedelta: ...
185 def __truediv__(self, __other: timedelta) -> float: ...
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: ...
197 class datetime(date):
198 min: ClassVar[datetime]
199 max: ClassVar[datetime]
200 resolution: ClassVar[timedelta]
209 microsecond: int = ...,
210 tzinfo: _tzinfo | None = ...,
215 def hour(self) -> int: ...
217 def minute(self) -> int: ...
219 def second(self) -> int: ...
221 def microsecond(self) -> int: ...
223 def tzinfo(self) -> _tzinfo | None: ...
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.
230 def fromtimestamp(cls: Type[_S], __timestamp: float, tz: _tzinfo | None = ...) -> _S: ...
232 def utcfromtimestamp(cls: Type[_S], __t: float) -> _S: ...
233 if sys.version_info >= (3, 8):
235 def now(cls: Type[_S], tz: _tzinfo | None = ...) -> _S: ...
239 def now(cls: Type[_S], tz: None = ...) -> _S: ...
242 def now(cls, tz: _tzinfo) -> datetime: ...
244 def utcnow(cls: Type[_S]) -> _S: ...
246 def combine(cls, date: _date, time: _time, tzinfo: _tzinfo | None = ...) -> datetime: ...
247 if sys.version_info >= (3, 7):
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: ...
263 microsecond: int = ...,
264 tzinfo: _tzinfo | None = ...,
268 if sys.version_info >= (3, 8):
269 def astimezone(self: _S, tz: _tzinfo | None = ...) -> _S: ...
271 def astimezone(self, tz: _tzinfo | None = ...) -> datetime: ...
272 def ctime(self) -> str: ...
273 def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
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: ...
287 def __sub__(self: _D, __other: _D) -> timedelta: ...
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: ...
295 def __sub__(self, __other: timedelta) -> datetime: ...
296 if sys.version_info >= (3, 9):
297 def isocalendar(self) -> _IsoCalendarDate: ...
299 def isocalendar(self) -> tuple[int, int, int]: ...