From 03c0a258a208badea56164517f37df44a6e24fc6 Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Sun, 20 Nov 2005 04:54:33 +0000 Subject: [PATCH] Fixed problem in microseconds conversion. --- ChangeLog | 6 ++++++ INSTALL | 13 ++++++++++++- psycopg/typecast.c | 9 ++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e59fe2ed..9b2affad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ +2005-11-20 Federico Di Gregorio + + * psycopg/typecast.c: fixed problem with microseconds conversion by + applying slightly modified patch from Ronnie Mackay. + 2005-11-19 Federico Di Gregorio * lib/extensions.py: COMMITED -> COMMITTED. (Closes: #73) + * doc/extensions.rst: included Daniele's work after minor cosmetic changes like using the new constants instead of numbers for transaction isolation levels. diff --git a/INSTALL b/INSTALL index 512bd18a..b45ce517 100644 --- a/INSTALL +++ b/INSTALL @@ -16,8 +16,19 @@ to build in the local directory; and: to install system-wide. +Using setuptools and EasyInstall +================================ + +If setuptools are installed on your system you can easily create an egg for +psycopg and install it. Download the source distribution (if you're reading +this file you probably already have) and then edit setup.cfg to your taste +and build from the source distribution top-level directory using: + + easy_install . + + Compiling under Windows with mingw32 -************************************ +==================================== You can compile psycopg under Windows platform with mingw32 compiler. The software required is: diff --git a/psycopg/typecast.c b/psycopg/typecast.c index 3ab51635..f351bfa5 100644 --- a/psycopg/typecast.c +++ b/psycopg/typecast.c @@ -88,6 +88,7 @@ typecast_parse_time(char* s, char** t, int* len, { int acc = -1, cz = 0; int tzs = 1, tzhh = 0, tzmm = 0; + int usd = 0; /* sets microseconds and timezone to 0 because they may be missing */ *us = *tz = 0; @@ -121,6 +122,7 @@ typecast_parse_time(char* s, char** t, int* len, break; default: acc = (acc == -1 ? 0 : acc*10) + ((int)*s - (int)'0'); + if (cz == 3) usd += 1; break; } @@ -136,7 +138,12 @@ typecast_parse_time(char* s, char** t, int* len, if (t != NULL) *t = s; *tz = tzs * tzhh*60 + tzmm; - + + if (*us != 0.0) { + while (usd < 6) + *us *= (*us)*10.0; + } + return cz; }