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>
|
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
|
* ZpsycopgDA/DA.py: we now split on GMT+, GMT-, + or -. This should
|
||||||
fix bug #129.
|
fix bug #129.
|
||||||
|
|
||||||
|
|
|
@ -280,22 +280,23 @@ psyco_Time(PyObject *self, PyObject *args)
|
||||||
PyObject *res = NULL;
|
PyObject *res = NULL;
|
||||||
PyObject *tzinfo = NULL;
|
PyObject *tzinfo = NULL;
|
||||||
int hours, minutes=0;
|
int hours, minutes=0;
|
||||||
double micro, seconds=0.0;
|
double micro, second=0.0;
|
||||||
|
|
||||||
PyObject* obj = NULL;
|
PyObject* obj = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "iid|O", &hours, &minutes, &seconds,
|
if (!PyArg_ParseTuple(args, "iid|O", &hours, &minutes, &second,
|
||||||
&tzinfo))
|
&tzinfo))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
micro = (seconds - floor(seconds)) * 1000000.0;
|
micro = (second - floor(second)) * 1000000.0;
|
||||||
|
second = floor(second);
|
||||||
|
|
||||||
if (tzinfo == NULL)
|
if (tzinfo == NULL)
|
||||||
obj = PyObject_CallFunction(pyTimeTypeP, "iiii",
|
obj = PyObject_CallFunction(pyTimeTypeP, "iiii",
|
||||||
hours, minutes, (int)round(seconds), (int)round(micro));
|
hours, minutes, (int)second, (int)round(micro));
|
||||||
else
|
else
|
||||||
obj = PyObject_CallFunction(pyTimeTypeP, "iiiiO",
|
obj = PyObject_CallFunction(pyTimeTypeP, "iiiiO",
|
||||||
hours, minutes, (int)round(seconds), (int)round(micro), tzinfo);
|
hours, minutes, (int)second, (int)round(micro), tzinfo);
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
res = PyObject_CallFunction((PyObject *)&pydatetimeType,
|
res = PyObject_CallFunction((PyObject *)&pydatetimeType,
|
||||||
|
@ -322,14 +323,15 @@ psyco_Timestamp(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
micro = (second - floor(second)) * 1000000.0;
|
micro = (second - floor(second)) * 1000000.0;
|
||||||
|
second = floor(second);
|
||||||
|
|
||||||
if (tzinfo == NULL)
|
if (tzinfo == NULL)
|
||||||
obj = PyObject_CallFunction(pyDateTimeTypeP, "iiiiiii",
|
obj = PyObject_CallFunction(pyDateTimeTypeP, "iiiiiii",
|
||||||
year, month, day, hour, minute, (int)round(second),
|
year, month, day, hour, minute, (int)second,
|
||||||
(int)round(micro));
|
(int)round(micro));
|
||||||
else
|
else
|
||||||
obj = PyObject_CallFunction(pyDateTimeTypeP, "iiiiiiiO",
|
obj = PyObject_CallFunction(pyDateTimeTypeP, "iiiiiiiO",
|
||||||
year, month, day, hour, minute, (int)round(second),
|
year, month, day, hour, minute, (int)second,
|
||||||
(int)round(micro), tzinfo);
|
(int)round(micro), tzinfo);
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user