Skip to content

module datetime

Source: stdlib/datetime.codon


MINYEAR = 1


MAXYEAR = 9999


MAXORDINAL = 3652059


MAX_DELTA_DAYS = 999999999


timedelta @tuple Class is named tuple (cannot write fields)

Fields

min: ClassVar[timedelta]

max: ClassVar[timedelta]

resolution: ClassVar[timedelta]

Properties

days @property Method is a class property

seconds @property Method is a class property

microseconds @property Method is a class property

Magic methods

__new__(days: float = 0, seconds: float = 0, microseconds: float = 0, milliseconds: float = 0, minutes: float = 0, hours: float = 0, weeks: float = 0)

__new__(days: int)

__repr__(self)

__str__(self)

__add__(self, other: timedelta)

__sub__(self, other: timedelta)

__mul__(self, other: int)

__rmul__(self, other: int)

__mul__(self, other: float)

__rmul__(self, other: float)

__truediv__(self, other: timedelta)

__truediv__(self, other: float)

__truediv__(self, other: int)

__floordiv__(self, other: timedelta)

__floordiv__(self, other: int)

__mod__(self, other: timedelta)

__divmod__(self, other: timedelta)

__pos__(self)

__neg__(self)

__abs__(self)

__eq__(self, other: timedelta)

__ne__(self, other: timedelta)

__lt__(self, other: timedelta)

__le__(self, other: timedelta)

__gt__(self, other: timedelta)

__ge__(self, other: timedelta)

__bool__(self)

Methods

total_seconds(self)


IsoCalendarDate @tuple Class is named tuple (cannot write fields)

Fields

year: int

week: int

weekday: int

Magic methods

__repr__(self)


date @tuple Class is named tuple (cannot write fields)

Fields

min: ClassVar[date]

max: ClassVar[date]

resolution: ClassVar[timedelta]

Properties

year @property Method is a class property

month @property Method is a class property

day @property Method is a class property

Magic methods

__new__(year: int, month: int, day: int)

__repr__(self)

__add__(self, other: timedelta)

__sub__(self, other: timedelta)

__sub__(self, other: date)

__eq__(self, other: date)

__ne__(self, other: date)

__lt__(self, other: date)

__le__(self, other: date)

__gt__(self, other: date)

__ge__(self, other: date)

__bool__(self)

__str__(self)

Methods

today()

fromtimestamp(timestamp)

fromordinal(ordinal: int)

fromisoformat(date_string: str)

fromisocalendar(year, week, day)

replace(self, year: int = -1, month: int = -1, day: int = -1)

timetuple(self)

toordinal(self)

weekday(self)

isoweekday(self)

isocalendar(self)

isoformat(self)

ctime(self)


time @tuple Class is named tuple (cannot write fields)

Fields

min: ClassVar[time]

max: ClassVar[time]

resolution: ClassVar[timedelta]

Properties

hour @property Method is a class property

minute @property Method is a class property

second @property Method is a class property

microsecond @property Method is a class property

Magic methods

__new__(hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0)

__repr__(self)

__str__(self)

__bool__(self)

Methods

fromisoformat(time_string: str)

replace(self, hour: int = -1, minute: int = -1, second: int = -1, microsecond: int = -1)

isoformat(self, timespec: Literal[str] = "auto")


datetime @tuple Class is named tuple (cannot write fields)

Fields

min: ClassVar[datetime]

max: ClassVar[datetime]

resolution: ClassVar[timedelta]

Properties

year @property Method is a class property

month @property Method is a class property

day @property Method is a class property

hour @property Method is a class property

minute @property Method is a class property

second @property Method is a class property

microsecond @property Method is a class property

Magic methods

__new__(year: int, month: int, day: int, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0)

__repr__(self)

__str__(self)

__add__(self, other: timedelta)

__sub__(self, other: timedelta)

__sub__(self, other: datetime)

__eq__(self, other: datetime)

__ne__(self, other: datetime)

__lt__(self, other: datetime)

__le__(self, other: datetime)

__gt__(self, other: datetime)

__ge__(self, other: datetime)

__bool__(self)

Methods

date(self)

time(self)

today()

now()

utcnow()

fromtimestamp(timestamp)

utcfromtimestamp(timestamp)

fromordinal(ordinal: int)

combine(date: date, time: time)

fromisoformat(date_string: str)

fromisocalendar(year: int, week: int, day: int)

replace(self, year: int = -1, month: int = -1, day: int = -1, hour: int = -1, minute: int = -1, second: int = -1, microsecond: int = -1)

timetuple(self)

utctimetuple(self)

toordinal(self)

timestamp(self)

weekday(self)

isoweekday(self)

isocalendar(self)

isoformat(self, sep: str = "T", timespec: Literal[str] = "auto")

ctime(self)


timedelta @extend Class is extended to add given methods

Magic methods

__add__(self, other: date)

__add__(self, other: datetime)