Fractionary seconds fix (closes: #130)

This commit is contained in:
Federico Di Gregorio 2006-09-30 06:16:24 +00:00
parent ca860424e6
commit 168d9c36af
2 changed files with 16 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2006-09-30 Federico Di Gregorio <fog@initd.org>
* psycopg/adapter_datetime.py: now TimeFromTicks and
TimestampFromTicks both accept fractionary seconds (fixes #130).
2006-09-23 Federico Di Gregorio <fog@initd.org>
* lib/errorcodes.py: added list of all PostgreSQL error codes
@ -6,6 +11,7 @@
* psycopg/psycopg.h: applied compatibility macros from PEP 353.
* Applied patch 1/3 from Piet Delport; from his email:
psycopg2-Py_ssize_t-input.diff adjusts variables used for parameters
and return values. These changes only prevent overflowing on values
greater than 32-bits, so they're not as critical as the other two
@ -14,12 +20,14 @@
either way, not being too familiar with the codebase.
* Applied patch 2/3 from Piet Delport; from his email:
psycopg2-Py_ssize_t-output.diff adjusts variables used as outputs
from CPython API calls: without it the calls try to write 64 bits
to 32 bit locations, trampling over adjacent values/pointers,
and segfaulting later.
* Applied patch 1/3 from Piet Delport; from his email:
psycopg2-PyObject_HEAD.diff adds missing underscores to several
"PyObject_HEAD" declarations. As far as i can tell from gdb, the
"PyObject HEAD" versions end up accidentally meaning almost exactly

View File

@ -375,8 +375,10 @@ psyco_TimeFromTicks(PyObject *self, PyObject *args)
return NULL;
t = (time_t)round(ticks);
ticks -= (double)t;
if (localtime_r(&t, &tm)) {
args = Py_BuildValue("iid", tm.tm_hour, tm.tm_min, (double)tm.tm_sec);
args = Py_BuildValue("iid", tm.tm_hour, tm.tm_min,
(double)tm.tm_sec + ticks);
if (args) {
res = psyco_Time(self, args);
Py_DECREF(args);
@ -397,10 +399,12 @@ psyco_TimestampFromTicks(PyObject *self, PyObject *args)
return NULL;
t = (time_t)round(ticks);
ticks -= (double)t;
if (localtime_r(&t, &tm)) {
args = Py_BuildValue("iiiiidO",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, (double)tm.tm_sec,
tm.tm_hour, tm.tm_min,
(double)tm.tm_sec + ticks,
pyPsycopgTzLOCAL);
if (args) {
res = psyco_Timestamp(self, args);