diff options
author | Federico Di Gregorio <fog@initd.org> | 2006-07-26 05:13:08 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2006-07-26 05:13:08 +0000 |
commit | b9f7c24a63aa703aa1f891d48d529a6fb3926a27 (patch) | |
tree | aabab065ee8b76c3d7997d87c270890bd077b764 /psycopg/adapter_datetime.c | |
parent | b9fcde1b39edaebb0ace2e4e9f5632d2962648c7 (diff) | |
download | psycopg2-b9f7c24a63aa703aa1f891d48d529a6fb3926a27.tar.gz |
Interval conversion fix.
Diffstat (limited to 'psycopg/adapter_datetime.c')
-rw-r--r-- | psycopg/adapter_datetime.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index 5079638..6409cef 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -64,15 +64,14 @@ pydatetime_str(pydatetimeObject *self) PyDateTime_Delta *obj = (PyDateTime_Delta*)self->wrapped; char buffer[8]; - int i, j, x; + int i; int a = obj->microseconds; - for (i=1000000, j=0; i > 0 ; i /= 10) { - x = a/i; - a -= x*i; - buffer[j++] = '0'+x; + for (i=0; i < 6 ; i++) { + buffer[5-i] = '0' + (a % 10); + a /= 10; } - buffer[j] = '\0'; + buffer[6] = '\0'; return PyString_FromFormat("'%d days %d.%s seconds'", obj->days, obj->seconds, buffer); |