TimestampFromTicks() throws ValueError (2-2.0.14)
Jozsef Szalay <jszalay-7JS02rSrduhWk0Htik3J/[email protected]> Thu, 6 May 2010 15:23:31 -0500
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
The following sequence results in an exception
import psycopg2
print psycopg2.TimestampFromTicks(1273173119.99992)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: second must be in 0..59
Applying the patch below produces the expected result
'2010-05-06T14:11:59.999920-05:00'
--- psycopg2-2.0.14/psycopg/adapter_datetime.c 2010-02-28 13:29:43.000000000 -0600
+++ psycopg2-2.0.14/psycopg/adapter_datetime.c~ 2010-05-06 14:57:38.000000000 -0500
@@ -416,7 +416,7 @@
if (!PyArg_ParseTuple(args, "d", &ticks))
return NULL;
- t = (time_t)round(ticks);
+ t = (time_t)floor(ticks);
ticks -= (double)t;
if (localtime_r(&t, &tm)) {
PyObject *value = Py_BuildValue("iiiiidO",
Thank you all for maintaining psycopg! Keep up the good work!
Jozsef Szalay
Data Architect
[cid:image001.jpg-8DFVJcsCHzo+jObtZeG/[email protected]]
jszalay-7JS02rSrduhWk0Htik3J/[email protected]
Direct +1 512.334.3106 | Fax +1 512.334.3121 | www.storediq.com
_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
image001.jpg
(image/jpeg, 3.2 KB) - not displayed