diff options
author | Paul Ganssle <pganssle@users.noreply.github.com> | 2018-01-24 22:29:30 (GMT) |
---|---|---|
committer | Alexander Belopolsky <abalkin@users.noreply.github.com> | 2018-01-24 22:29:30 (GMT) |
commit | 04af5b1ba9eb546a29735fac6cb5298159069b53 (patch) | |
tree | 12e50adcc6ee03a3a4a80cb0a9b37bff4b58901b /Include | |
parent | ccbe5818af20f8c12043f5c30c277a74714405e0 (diff) | |
download | cpython-04af5b1ba9eb546a29735fac6cb5298159069b53.zip cpython-04af5b1ba9eb546a29735fac6cb5298159069b53.tar.gz cpython-04af5b1ba9eb546a29735fac6cb5298159069b53.tar.bz2 |
bpo-10381: Add timezone to datetime C API (#5032)
* Add timezone to datetime C API
* Add documentation for timezone C API macros
* Add dedicated tests for datetime type check macros
* Remove superfluous C API test
* Drop support for TimeZoneType in datetime C API
* Expose UTC singleton to the datetime C API
* Update datetime C-API documentation to include links
* Add reference count information for timezone constructors
Diffstat (limited to 'Include')
-rw-r--r-- | Include/datetime.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Include/datetime.h b/Include/datetime.h index 3bf35cb..059d5ec 100644 --- a/Include/datetime.h +++ b/Include/datetime.h @@ -155,12 +155,16 @@ typedef struct { PyTypeObject *DeltaType; PyTypeObject *TZInfoType; + /* singletons */ + PyObject *TimeZone_UTC; + /* constructors */ PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*); PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, PyObject*, PyTypeObject*); PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*); PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*); + PyObject *(*TimeZone_FromTimeZone)(PyObject *offset, PyObject *name); /* constructors for the DB API */ PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*); @@ -202,6 +206,9 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL; #define PyDateTime_IMPORT \ PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) +/* Macro for access to the UTC singleton */ +#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC + /* Macros for type checking when not building the Python core. */ #define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) #define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType) @@ -242,6 +249,12 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL; PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \ PyDateTimeAPI->DeltaType) +#define PyTimeZone_FromOffset(offset) \ + PyDateTimeAPI->TimeZone_FromTimeZone(offset, NULL) + +#define PyTimeZone_FromOffsetAndName(offset, name) \ + PyDateTimeAPI->TimeZone_FromTimeZone(offset, name) + /* Macros supporting the DB API. */ #define PyDateTime_FromTimestamp(args) \ PyDateTimeAPI->DateTime_FromTimestamp( \ |