Usage of PyDateTime_FromTimestamp
Andreas
aww.dev at googlemail.com
Tue Aug 30 23:39:33 EDT 2011
Am 30.08.2011 23:49, schrieb MRAB:
> The key phrase is "argument tuple". The arguments passed to a Python
> call are always a tuple, not PyFloat_Object.
>
> You can build a tuple from the PyFloat_Object using:
>
> Py_BuildValue("(O)", float_object)
>
> The "(O)" says to build a tuple ("(...)") containing a single object
> ("O").
Thank you very much! That solved my problem.
Here the full working example:
static double doubleValue = 1314761451;
PyObject *floatObj = NULL;
PyObject *timeTuple = NULL;
PyObject *dateTime = NULL;
floatObj = PyFloat_FromDouble(doubleValue);
timeTuple = Py_BuildValue("(O)", floatObj);
dateTime = PyDateTime_FromTimestamp(timeTuple);
More information about the Python-list
mailing list