diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | psycopg/adapter_datetime.c | 8 |
2 files changed, 16 insertions, 4 deletions
@@ -1,11 +1,17 @@ +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 - compiled by Johan Dahlin. + compiled by Johan Dahlin. * 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,13 +20,15 @@ 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 + + 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 the same, but get aligned differently on AMD64, resulting in wrong diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index 6409cef..9129ca6 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -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); |