Skip to main content

datetime

Standard library Module View source
variable MINYEAR
MINYEAR = 1
variable MAXYEAR
MAXYEAR = 9999
variable MAXORDINAL
MAXORDINAL = 3652059
variable MAX_DELTA_DAYS
MAX_DELTA_DAYS = 999999999
class timedelta
@tuple
class timedelta
Fields 3
min ClassVar[timedelta]
max ClassVar[timedelta]
resolution ClassVar[timedelta]
Constructors 2
__new__
__new__(days: float = 0, seconds: float = 0, microseconds: float = 0, milliseconds: float = 0, minutes: float = 0, hours: float = 0, weeks: float = 0) -> timedelta
__new__
__new__(days: int) -> timedelta
Properties 3
days
@property
days(self: Self) -> int
seconds
@property
seconds(self: Self) -> int
microseconds
@property
microseconds(self: Self) -> int
Methods 1
total_seconds
total_seconds(self: Self, /) -> float
Special methods 20
__repr__
__repr__(self: Self, /) -> str
__str__
__str__(self: Self, /) -> str
__add__
__add__(self: Self, other: timedelta, /) -> timedelta
__sub__
__sub__(self: Self, other: timedelta, /) -> timedelta
__mul__
__mul__(self: Self, other: int, /) -> timedelta
__mul__(self: Self, other: float, /) -> timedelta
__rmul__
__rmul__(self: Self, other: int, /) -> timedelta
__rmul__(self: Self, other: float, /) -> timedelta
__truediv__
__truediv__(self: Self, other: timedelta, /) -> float
__truediv__(self: Self, other: float, /) -> timedelta
__truediv__(self: Self, other: int, /) -> timedelta
__floordiv__
__floordiv__(self: Self, other: timedelta, /) -> int
__floordiv__(self: Self, other: int, /) -> timedelta
__mod__
__mod__(self: Self, other: timedelta, /) -> timedelta
__divmod__
__divmod__(self: Self, other: timedelta, /) -> Tuple[(int, timedelta)]
__pos__
__pos__(self: Self, /) -> timedelta
__neg__
__neg__(self: Self, /) -> timedelta
__abs__
__abs__(self: Self, /) -> timedelta
__eq__
__eq__(self: Self, other: timedelta, /) -> bool
__ne__
__ne__(self: Self, other: timedelta, /) -> bool
__lt__
__lt__(self: Self, other: timedelta, /) -> bool
__le__
__le__(self: Self, other: timedelta, /) -> bool
__gt__
__gt__(self: Self, other: timedelta, /) -> bool
__ge__
__ge__(self: Self, other: timedelta, /) -> bool
__bool__
__bool__(self: Self, /) -> bool
class IsoCalendarDate
@tuple
class IsoCalendarDate
Fields 3
year int
week int
weekday int
Special methods 1
__repr__
__repr__(self: Self) -> str
class date
@tuple
class date
Fields 3
min ClassVar[date]
max ClassVar[date]
resolution ClassVar[timedelta]
Constructors 1
__new__
__new__(year: int, month: int, day: int) -> date
Properties 3
year
@property
year(self: Self) -> int
month
@property
month(self: Self) -> int
day
@property
day(self: Self) -> int
Methods 13
today
today() -> date
fromtimestamp
fromtimestamp(timestamp, /) -> date
fromordinal
fromordinal(ordinal: int, /) -> date
fromisoformat
fromisoformat(date_string: str, /) -> date
fromisocalendar
fromisocalendar(year, week, day) -> date
replace
replace(self: Self, /, year: int = -1, month: int = -1, day: int = -1) -> date
timetuple
timetuple(self: Self, /) -> struct_time
toordinal
toordinal(self: Self, /) -> int
weekday
weekday(self: Self, /) -> int
isoweekday
isoweekday(self: Self, /) -> int
isocalendar
isocalendar(self: Self, /) -> IsoCalendarDate
isoformat
isoformat(self: Self, /) -> str
ctime
ctime(self: Self, /) -> str
Special methods 11
__repr__
__repr__(self: Self, /) -> str
__add__
__add__(self: Self, other: timedelta, /) -> date
__sub__
__sub__(self: Self, other: timedelta, /) -> date
__sub__(self: Self, other: date, /) -> timedelta
__eq__
__eq__(self: Self, other: date, /) -> bool
__ne__
__ne__(self: Self, other: date, /) -> bool
__lt__
__lt__(self: Self, other: date, /) -> bool
__le__
__le__(self: Self, other: date, /) -> bool
__gt__
__gt__(self: Self, other: date, /) -> bool
__ge__
__ge__(self: Self, other: date, /) -> bool
__bool__
__bool__(self: Self) -> bool
__str__
__str__(self: Self, /) -> str
class time
@tuple
class time
Fields 3
min ClassVar[time]
max ClassVar[time]
resolution ClassVar[timedelta]
Constructors 1
__new__
__new__(hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0) -> time
Properties 4
hour
@property
hour(self: Self) -> int
minute
@property
minute(self: Self) -> int
second
@property
second(self: Self) -> int
microsecond
@property
microsecond(self: Self) -> int
Methods 3
fromisoformat
fromisoformat(time_string: str, /) -> time
replace
replace(self: Self, /, hour: int = -1, minute: int = -1, second: int = -1, microsecond: int = -1) -> time
isoformat
isoformat[timespec: Literal[str] = "auto"](self: Self, /) -> str
Special methods 3
__repr__
__repr__(self: Self, /) -> str
__str__
__str__(self: Self, /) -> str
__bool__
__bool__(self: Self) -> bool
class datetime
@tuple
class datetime
Fields 3
min ClassVar[datetime]
max ClassVar[datetime]
resolution ClassVar[timedelta]
Constructors 1
__new__
__new__(year: int, month: int, day: int, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0) -> datetime
Properties 7
year
@property
year(self: Self) -> int
month
@property
month(self: Self) -> int
day
@property
day(self: Self) -> int
hour
@property
hour(self: Self) -> int
minute
@property
minute(self: Self) -> int
second
@property
second(self: Self) -> int
microsecond
@property
microsecond(self: Self) -> int
Methods 21
date
date(self: Self, /) -> date
time
time(self: Self, /) -> time
today
today() -> datetime
now
now() -> datetime
utcnow
utcnow() -> datetime
fromtimestamp
fromtimestamp(timestamp) -> datetime
utcfromtimestamp
utcfromtimestamp(timestamp, /) -> datetime
fromordinal
fromordinal(ordinal: int, /) -> datetime
combine
combine(date: date, time: time) -> datetime
fromisoformat
fromisoformat(date_string: str, /) -> datetime
fromisocalendar
fromisocalendar(year: int, week: int, day: int) -> datetime
replace
replace(self: Self, /, year: int = -1, month: int = -1, day: int = -1, hour: int = -1, minute: int = -1, second: int = -1, microsecond: int = -1) -> datetime
timetuple
timetuple(self: Self, /) -> struct_time
utctimetuple
utctimetuple(self: Self, /) -> struct_time
toordinal
toordinal(self: Self, /) -> int
timestamp
timestamp(self: Self, /) -> float
weekday
weekday(self: Self, /) -> int
isoweekday
isoweekday(self: Self, /) -> int
isocalendar
isocalendar(self: Self, /) -> IsoCalendarDate
isoformat
isoformat[timespec: Literal[str] = "auto"](self: Self, /, sep: str = "T") -> str
ctime
ctime(self: Self, /) -> str
Special methods 11
__repr__
__repr__(self: Self, /) -> str
__str__
__str__(self: Self, /) -> str
__add__
__add__(self: Self, other: timedelta, /) -> datetime
__sub__
__sub__(self: Self, other: timedelta, /) -> datetime
__sub__(self: Self, other: datetime, /) -> timedelta
__eq__
__eq__(self: Self, other: datetime, /) -> bool
__ne__
__ne__(self: Self, other: datetime, /) -> bool
__lt__
__lt__(self: Self, other: datetime, /) -> bool
__le__
__le__(self: Self, other: datetime, /) -> bool
__gt__
__gt__(self: Self, other: datetime, /) -> bool
__ge__
__ge__(self: Self, other: datetime, /) -> bool
__bool__
__bool__(self: Self) -> bool