Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12460

Re: Usage of PyDateTime_FromTimestamp

From Andreas <aww.dev@googlemail.com>
Subject Re: Usage of PyDateTime_FromTimestamp
Date 2011-08-31 05:39 +0200
References <j3jhvm$8o8$1@dough.gmane.org> <4E5D5AD0.9070408@mrabarnett.plus.com>
Newsgroups comp.lang.python
Message-ID <mailman.592.1314761989.27778.python-list@python.org> (permalink)

Show all headers | View raw


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);



Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Usage of PyDateTime_FromTimestamp Andreas <aww.dev@googlemail.com> - 2011-08-31 05:39 +0200

csiph-web