datetime
Basic local dates and times, backed by time.localtime().
from datetime import date, datetime
deadline = date(2026, 10, 2)
meeting = datetime(2026, 10, 2, 9, 30, 0)
assert meeting.date() == deadline
assert str(meeting) == '2026-10-02 09:30:00'
assert date(2026, 10, 1) < deadline
Dates and datetimes support field access, string representations, and
comparisons. This module does not implement timezone objects, parsing with
strptime, formatting with strftime, microseconds, or date arithmetic.
timedelta stores its two fields without CPython's normalization and
arithmetic behavior. Validate calendar inputs in your application; the date
constructor does not perform full calendar validation.
Implementation: datetime.py.