summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2006-09-30 06:16:24 +0000
committerFederico Di Gregorio <fog@initd.org>2006-09-30 06:16:24 +0000
commit168d9c36afda957921349f39b934b0acf9cd6b65 (patch)
tree30b8531865e098896502eccd6c9c3819ada3152d
parentca860424e6a7ae486b58b0f57d0691b372de59f5 (diff)
downloadpsycopg2-168d9c36afda957921349f39b934b0acf9cd6b65.tar.gz
Fractionary seconds fix (closes: #130)
-rw-r--r--ChangeLog12
-rw-r--r--psycopg/adapter_datetime.c8
2 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 23c72a8..8463f39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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);