|
| 1 | +from datetime import ( |
| 2 | + date as _date, |
| 3 | + datetime, |
| 4 | + time as _time, |
| 5 | + timedelta, |
| 6 | + tzinfo as _tzinfo, |
| 7 | +) |
| 8 | +import sys |
| 9 | +from time import struct_time |
| 10 | +from typing import ( |
| 11 | + ClassVar, |
| 12 | + Optional, |
| 13 | + Type, |
| 14 | + TypeVar, |
| 15 | + overload, |
| 16 | +) |
| 17 | + |
| 18 | +import numpy as np |
| 19 | + |
| 20 | +from pandas._libs.tslibs import ( |
| 21 | + NaT, |
| 22 | + NaTType, |
| 23 | + Period, |
| 24 | + Timedelta, |
| 25 | +) |
| 26 | + |
| 27 | +_S = TypeVar("_S") |
| 28 | + |
| 29 | + |
| 30 | +def integer_op_not_supported(obj) -> None: ... |
| 31 | + |
| 32 | + |
| 33 | +class Timestamp(datetime): |
| 34 | + min: ClassVar[Timestamp] |
| 35 | + max: ClassVar[Timestamp] |
| 36 | + |
| 37 | + resolution: ClassVar[Timedelta] |
| 38 | + value: int # np.int64 |
| 39 | + |
| 40 | + # error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]") |
| 41 | + def __new__( # type: ignore[misc] |
| 42 | + cls: Type[_S], |
| 43 | + ts_input: int | np.integer | float | str | _date | datetime | np.datetime64 = ..., |
| 44 | + freq=..., |
| 45 | + tz: str | _tzinfo | None | int= ..., |
| 46 | + unit=..., |
| 47 | + year: int | None = ..., |
| 48 | + month: int | None = ..., |
| 49 | + day: int | None = ..., |
| 50 | + hour: int | None = ..., |
| 51 | + minute: int | None = ..., |
| 52 | + second: int | None = ..., |
| 53 | + microsecond: int | None = ..., |
| 54 | + nanosecond: int | None = ..., |
| 55 | + tzinfo: _tzinfo | None = ..., |
| 56 | + *, |
| 57 | + fold: int | None= ..., |
| 58 | + ) -> _S | NaTType: ... |
| 59 | + |
| 60 | + @property |
| 61 | + def year(self) -> int: ... |
| 62 | + @property |
| 63 | + def month(self) -> int: ... |
| 64 | + @property |
| 65 | + def day(self) -> int: ... |
| 66 | + @property |
| 67 | + def hour(self) -> int: ... |
| 68 | + @property |
| 69 | + def minute(self) -> int: ... |
| 70 | + @property |
| 71 | + def second(self) -> int: ... |
| 72 | + @property |
| 73 | + def microsecond(self) -> int: ... |
| 74 | + @property |
| 75 | + def tzinfo(self) -> Optional[_tzinfo]: ... |
| 76 | + @property |
| 77 | + def tz(self) -> Optional[_tzinfo]: ... |
| 78 | + |
| 79 | + @property |
| 80 | + def fold(self) -> int: ... |
| 81 | + |
| 82 | + @classmethod |
| 83 | + def fromtimestamp(cls: Type[_S], t: float, tz: Optional[_tzinfo] = ...) -> _S: ... |
| 84 | + @classmethod |
| 85 | + def utcfromtimestamp(cls: Type[_S], t: float) -> _S: ... |
| 86 | + @classmethod |
| 87 | + def today(cls: Type[_S]) -> _S: ... |
| 88 | + @classmethod |
| 89 | + def fromordinal(cls: Type[_S], n: int) -> _S: ... |
| 90 | + |
| 91 | + if sys.version_info >= (3, 8): |
| 92 | + @classmethod |
| 93 | + def now(cls: Type[_S], tz: _tzinfo | str | None = ...) -> _S: ... |
| 94 | + else: |
| 95 | + @overload |
| 96 | + @classmethod |
| 97 | + def now(cls: Type[_S], tz: None = ...) -> _S: ... |
| 98 | + @overload |
| 99 | + @classmethod |
| 100 | + def now(cls, tz: _tzinfo) -> datetime: ... |
| 101 | + |
| 102 | + @classmethod |
| 103 | + def utcnow(cls: Type[_S]) -> _S: ... |
| 104 | + @classmethod |
| 105 | + def combine(cls, date: _date, time: _time, tzinfo: Optional[_tzinfo] = ...) -> datetime: ... |
| 106 | + |
| 107 | + @classmethod |
| 108 | + def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... |
| 109 | + |
| 110 | + def strftime(self, fmt: str) -> str: ... |
| 111 | + def __format__(self, fmt: str) -> str: ... |
| 112 | + |
| 113 | + def toordinal(self) -> int: ... |
| 114 | + def timetuple(self) -> struct_time: ... |
| 115 | + |
| 116 | + def timestamp(self) -> float: ... |
| 117 | + |
| 118 | + def utctimetuple(self) -> struct_time: ... |
| 119 | + def date(self) -> _date: ... |
| 120 | + def time(self) -> _time: ... |
| 121 | + def timetz(self) -> _time: ... |
| 122 | + |
| 123 | + def replace( |
| 124 | + self, |
| 125 | + year: int = ..., |
| 126 | + month: int = ..., |
| 127 | + day: int = ..., |
| 128 | + hour: int = ..., |
| 129 | + minute: int = ..., |
| 130 | + second: int = ..., |
| 131 | + microsecond: int = ..., |
| 132 | + tzinfo: Optional[_tzinfo] = ..., |
| 133 | + *, |
| 134 | + fold: int = ..., |
| 135 | + ) -> datetime: ... |
| 136 | + |
| 137 | + if sys.version_info >= (3, 8): |
| 138 | + def astimezone(self: _S, tz: Optional[_tzinfo] = ...) -> _S: ... |
| 139 | + else: |
| 140 | + def astimezone(self, tz: Optional[_tzinfo] = ...) -> datetime: ... |
| 141 | + |
| 142 | + def ctime(self) -> str: ... |
| 143 | + def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ... |
| 144 | + |
| 145 | + @classmethod |
| 146 | + def strptime(cls, date_string: str, format: str) -> datetime: ... |
| 147 | + |
| 148 | + def utcoffset(self) -> Optional[timedelta]: ... |
| 149 | + def tzname(self) -> Optional[str]: ... |
| 150 | + def dst(self) -> Optional[timedelta]: ... |
| 151 | + |
| 152 | + def __le__(self, other: datetime) -> bool: ... # type: ignore |
| 153 | + def __lt__(self, other: datetime) -> bool: ... # type: ignore |
| 154 | + def __ge__(self, other: datetime) -> bool: ... # type: ignore |
| 155 | + def __gt__(self, other: datetime) -> bool: ... # type: ignore |
| 156 | + if sys.version_info >= (3, 8): |
| 157 | + def __add__(self: _S, other: timedelta) -> _S: ... |
| 158 | + def __radd__(self: _S, other: timedelta) -> _S: ... |
| 159 | + else: |
| 160 | + def __add__(self, other: timedelta) -> datetime: ... |
| 161 | + def __radd__(self, other: timedelta) -> datetime: ... |
| 162 | + @overload # type: ignore |
| 163 | + def __sub__(self, other: datetime) -> timedelta: ... |
| 164 | + @overload |
| 165 | + def __sub__(self, other: timedelta) -> datetime: ... |
| 166 | + |
| 167 | + def __hash__(self) -> int: ... |
| 168 | + def weekday(self) -> int: ... |
| 169 | + def isoweekday(self) -> int: ... |
| 170 | + def isocalendar(self) -> tuple[int, int, int]: ... |
| 171 | + |
| 172 | + @property |
| 173 | + def is_leap_year(self) -> bool: ... |
| 174 | + @property |
| 175 | + def is_month_start(self) -> bool: ... |
| 176 | + @property |
| 177 | + def is_quarter_start(self) -> bool: ... |
| 178 | + @property |
| 179 | + def is_year_start(self) -> bool: ... |
| 180 | + @property |
| 181 | + def is_month_end(self) -> bool: ... |
| 182 | + @property |
| 183 | + def is_quarter_end(self) -> bool: ... |
| 184 | + @property |
| 185 | + def is_year_end(self) -> bool: ... |
| 186 | + |
| 187 | + def to_pydatetime(self, warn: bool = ...) -> datetime: ... |
| 188 | + def to_datetime64(self) -> np.datetime64: ... |
| 189 | + def to_period(self, freq) -> Period: ... |
| 190 | + def to_julian_date(self) -> np.float64: ... |
| 191 | + |
| 192 | + @property |
| 193 | + def asm8(self) -> np.datetime64: ... |
| 194 | + |
| 195 | + def tz_convert(self: _S, tz) -> _S: ... |
| 196 | + |
| 197 | + # TODO: could return NaT? |
| 198 | + def tz_localize(self: _S, tz, ambiguous: str = ..., nonexistent: str = ...) -> _S: ... |
| 199 | + |
| 200 | + def normalize(self: _S) -> _S: ... |
| 201 | + |
| 202 | + # TODO: round/floor/ceil could return NaT? |
| 203 | + def round(self: _S, freq, ambiguous: bool | str = ..., nonexistent: str = ...) -> _S: ... |
| 204 | + def floor(self: _S, freq, ambiguous: bool | str = ..., nonexistent: str = ...) -> _S: ... |
| 205 | + def ceil(self: _S, freq, ambiguous: bool | str = ..., nonexistent: str = ...) -> _S: ... |
0 commit comments