~psycopg/psycopg/2.0.x

« back to all changes in this revision

Viewing changes to psycopg/typecast.c

  • Committer: Federico Di Gregorio
  • Date: 2005-11-20 04:54:33 UTC
  • Revision ID: fog-103d49c98779617785445beaea41dde2a376c085
Fixed problem in microseconds conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
{
89
89
    int acc = -1, cz = 0;
90
90
    int tzs = 1, tzhh = 0, tzmm = 0;
 
91
    int usd = 0;
91
92
    
92
93
    /* sets microseconds and timezone to 0 because they may be missing */
93
94
    *us = *tz = 0;
121
122
            break;
122
123
        default:
123
124
            acc = (acc == -1 ? 0 : acc*10) + ((int)*s - (int)'0');
 
125
            if (cz == 3) usd += 1;
124
126
            break;            
125
127
        }
126
128
 
136
138
    if (t != NULL) *t = s;
137
139
    
138
140
    *tz = tzs * tzhh*60 + tzmm;
139
 
 
 
141
    
 
142
    if (*us != 0.0) {
 
143
        while (usd < 6)
 
144
            *us *= (*us)*10.0;
 
145
    }
 
146
    
140
147
    return cz;
141
148
}
142
149