⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here
Expand description

FFI bindings to the functions and structs defined in datetime.h

This is the unsafe thin wrapper around the CPython C API, and covers the various date and time related objects in the Python datetime standard library module.

A note regarding PyPy (cpyext) support:

Support for PyDateTime_CAPI is limited as of PyPy 7.0.0. DateTime_FromTimestamp and Date_FromTimestamp are currently not supported.

Macros

Structs

Structure representing a datetime.date

Structure representing a datetime.datetime

Structure representing a datetime.timedelta.

Structure representing a datetime.time.

Constants

Statics

Functions

Returns a pointer to a PyDateTime_CAPI instance

Check if op is a PyDateTimeAPI.DateTimeType or subtype.

Check if op’s type is exactly PyDateTimeAPI.DateTimeType.

Retrieve the fold component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 1]

Retrieve the hour component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 23]

Retrieve the microsecond component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 999999]

Retrieve the minute component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 59]

Retrieve the second component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 59]

Retrieve the tzinfo component of a PyDateTime_DateTime. Returns a pointer to a PyObject that should be either NULL or an instance of a datetime.tzinfo subclass.

Retrieve the days component of a PyDateTime_Delta.

Retrieve the seconds component of a PyDateTime_Delta.

Retrieve the seconds component of a PyDateTime_Delta.

Retrieve the day component of a PyDateTime_Date or PyDateTime_DateTime. Returns a signed integer in the interval [1, 31].

Retrieve the month component of a PyDateTime_Date or PyDateTime_DateTime. Returns a signed integer in the range [1, 12].

Retrieve the year component of a PyDateTime_Date or PyDateTime_DateTime. Returns a signed integer greater than 0.

Populates the PyDateTimeAPI object

Retrieve the fold component of a PyDateTime_Time. Returns a signed integer in the interval [0, 1]

Retrieve the hour component of a PyDateTime_Time. Returns a signed integer in the interval [0, 23]

Retrieve the microsecond component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 999999]

Retrieve the minute component of a PyDateTime_Time. Returns a signed integer in the interval [0, 59]

Retrieve the second component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 59]

Retrieve the tzinfo component of a PyDateTime_Time. Returns a pointer to a PyObject that should be either NULL or an instance of a datetime.tzinfo subclass.

Type Check macros

Check if op’s type is exactly PyDateTimeAPI.DateType.

Check if op is a PyDateTimeAPI.DetaType or subtype.

Check if op’s type is exactly PyDateTimeAPI.DeltaType.

Check if op is a PyDateTimeAPI.TZInfoType or subtype.

Check if op’s type is exactly PyDateTimeAPI.TZInfoType.

Check if op is a PyDateTimeAPI.TimeType or subtype.

Check if op’s type is exactly PyDateTimeAPI.TimeType.