diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2019-12-03 22:59:35 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2019-12-05 15:06:44 +0100 |
commit | 12a74c66c6656bbf6a89bfae83b76e3df37d9199 (patch) | |
tree | 189bc4543ff839662d4032dbf66cd2e283f17829 /src/py_times.cc | |
parent | 23d818175a81e46a899c5e8b00be54cfa0881a4e (diff) | |
download | fork-ledger-12a74c66c6656bbf6a89bfae83b76e3df37d9199.tar.gz fork-ledger-12a74c66c6656bbf6a89bfae83b76e3df37d9199.tar.bz2 fork-ledger-12a74c66c6656bbf6a89bfae83b76e3df37d9199.zip |
Port to python3
Diffstat (limited to 'src/py_times.cc')
-rw-r--r-- | src/py_times.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/py_times.cc b/src/py_times.cc index bbd6f69a..6b2df443 100644 --- a/src/py_times.cc +++ b/src/py_times.cc @@ -30,6 +30,7 @@ */ #include <system.hh> +#include <datetime.h> #include "pyinterp.h" #include "pyutils.h" @@ -41,16 +42,11 @@ namespace ledger { using namespace boost::python; -#define MY_PyDateTime_IMPORT \ - PyDateTimeAPI = (PyDateTime_CAPI*) \ - PyCObject_Import(const_cast<char *>("datetime"), \ - const_cast<char *>("datetime_CAPI")) - struct date_to_python { static PyObject* convert(const date_t& dte) { - MY_PyDateTime_IMPORT; + PyDateTime_IMPORT; return PyDate_FromDate(dte.year(), dte.month(), dte.day()); } }; @@ -59,7 +55,7 @@ struct date_from_python { static void* convertible(PyObject* obj_ptr) { - MY_PyDateTime_IMPORT; + PyDateTime_IMPORT; if (PyDate_Check(obj_ptr)) return obj_ptr; return 0; } @@ -67,7 +63,7 @@ struct date_from_python static void construct(PyObject * obj_ptr, converter::rvalue_from_python_stage1_data * data) { - MY_PyDateTime_IMPORT; + PyDateTime_IMPORT; int year = PyDateTime_GET_YEAR(obj_ptr); date::year_type y = gregorian::greg_year(static_cast<unsigned short>(year)); @@ -90,7 +86,7 @@ struct datetime_to_python { static PyObject* convert(const datetime_t& moment) { - MY_PyDateTime_IMPORT; + PyDateTime_IMPORT; date_t dte = moment.date(); datetime_t::time_duration_type tod = moment.time_of_day(); @@ -107,7 +103,7 @@ struct datetime_from_python { static void* convertible(PyObject* obj_ptr) { - MY_PyDateTime_IMPORT; + PyDateTime_IMPORT; if (PyDateTime_Check(obj_ptr)) return obj_ptr; return 0; } @@ -115,7 +111,7 @@ struct datetime_from_python static void construct(PyObject * obj_ptr, converter::rvalue_from_python_stage1_data * data) { - MY_PyDateTime_IMPORT; + PyDateTime_IMPORT; int year = PyDateTime_GET_YEAR(obj_ptr); date::year_type y = gregorian::greg_year(static_cast<unsigned short>(year)); |