mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Fixed fractionary seconds >59 problem (closes: #131)
This commit is contained in:
parent
bc580e3383
commit
4820213b7f
|
@ -1,5 +1,8 @@
|
|||
2006-09-30 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/adapter_datetime.py: fixed conversion problem with seconds
|
||||
in the (59,60) range (fixes #131).
|
||||
|
||||
* ZpsycopgDA/DA.py: we now split on GMT+, GMT-, + or -. This should
|
||||
fix bug #129.
|
||||
|
||||
|
|
|
@ -280,22 +280,23 @@ psyco_Time(PyObject *self, PyObject *args)
|
|||
PyObject *res = NULL;
|
||||
PyObject *tzinfo = NULL;
|
||||
int hours, minutes=0;
|
||||
double micro, seconds=0.0;
|
||||
double micro, second=0.0;
|
||||
|
||||
PyObject* obj = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iid|O", &hours, &minutes, &seconds,
|
||||
if (!PyArg_ParseTuple(args, "iid|O", &hours, &minutes, &second,
|
||||
&tzinfo))
|
||||
return NULL;
|
||||
|
||||
micro = (seconds - floor(seconds)) * 1000000.0;
|
||||
micro = (second - floor(second)) * 1000000.0;
|
||||
second = floor(second);
|
||||
|
||||
if (tzinfo == NULL)
|
||||
obj = PyObject_CallFunction(pyTimeTypeP, "iiii",
|
||||
hours, minutes, (int)round(seconds), (int)round(micro));
|
||||
hours, minutes, (int)second, (int)round(micro));
|
||||
else
|
||||
obj = PyObject_CallFunction(pyTimeTypeP, "iiiiO",
|
||||
hours, minutes, (int)round(seconds), (int)round(micro), tzinfo);
|
||||
hours, minutes, (int)second, (int)round(micro), tzinfo);
|
||||
|
||||
if (obj) {
|
||||
res = PyObject_CallFunction((PyObject *)&pydatetimeType,
|
||||
|
@ -322,14 +323,15 @@ psyco_Timestamp(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
|
||||
micro = (second - floor(second)) * 1000000.0;
|
||||
second = floor(second);
|
||||
|
||||
if (tzinfo == NULL)
|
||||
obj = PyObject_CallFunction(pyDateTimeTypeP, "iiiiiii",
|
||||
year, month, day, hour, minute, (int)round(second),
|
||||
year, month, day, hour, minute, (int)second,
|
||||
(int)round(micro));
|
||||
else
|
||||
obj = PyObject_CallFunction(pyDateTimeTypeP, "iiiiiiiO",
|
||||
year, month, day, hour, minute, (int)round(second),
|
||||
year, month, day, hour, minute, (int)second,
|
||||
(int)round(micro), tzinfo);
|
||||
|
||||
if (obj) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user