diff options
| author | Federico Di Gregorio <fog@initd.org> | 2005-10-18 14:44:57 +0000 |
|---|---|---|
| committer | Federico Di Gregorio <fog@initd.org> | 2005-10-18 14:44:57 +0000 |
| commit | 49a255059e6873e9c26ca80e4f0f7f3e0e997977 (patch) | |
| tree | bb063c6229ec175284a53edf408b9c732583a51a /psycopg/adapter_mxdatetime.c | |
| parent | 8d4607ebbde66325c3a560c1ea16f5108d113fd6 (diff) | |
| download | psycopg2-49a255059e6873e9c26ca80e4f0f7f3e0e997977.tar.gz | |
Releasing 2.0 beta 5.2_0_BETA_5
Diffstat (limited to 'psycopg/adapter_mxdatetime.c')
| -rw-r--r-- | psycopg/adapter_mxdatetime.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/psycopg/adapter_mxdatetime.c b/psycopg/adapter_mxdatetime.c index f6547f4..dcc24d4 100644 --- a/psycopg/adapter_mxdatetime.c +++ b/psycopg/adapter_mxdatetime.c @@ -45,30 +45,26 @@ mxdatetime_str(mxdatetimeObject *self) PyObject *res = NULL; char *buffer = NULL; - mxDateTimeObject *obj = (mxDateTimeObject*)self->wrapped; + /* mxDateTimeObject *obj = (mxDateTimeObject*)self->wrapped; */ switch (self->type) { - case 0: - asprintf(&buffer, "'%02d:%02d:%.6f'", - (int)obj->hour, (int)obj->minute, (float)obj->second); - if (buffer) res = PyString_FromString(buffer); + case PSYCO_MXDATETIME_TIME: + res = PyObject_CallMethod(self->wrapped, "strftime", "s", + "'%H:%M:%S'"); break; - case 1: - asprintf(&buffer, "'%ld-%02d-%02d'", - obj->year, (int)obj->month, (int)obj->day); - if (buffer) res = PyString_FromString(buffer); + case PSYCO_MXDATETIME_DATE: + res = PyObject_CallMethod(self->wrapped, "strftime", "s", + "'%Y-%m-%d'"); break; - case 2: - asprintf(&buffer, "'%ld-%02d-%02d %02d:%02d:%.6f'", - obj->year, (int)obj->month, (int)obj->day, - (int)obj->hour, (int)obj->minute, (float)obj->second); - if (buffer) res = PyString_FromString(buffer); + case PSYCO_MXDATETIME_TIMESTAMP: + res = PyObject_CallMethod(self->wrapped, "strftime", "s", + "'%Y-%m-%dT%H:%M:%S'"); break; - case 3: + case PSYCO_MXDATETIME_INTERVAL: res = PyObject_CallMethod(self->wrapped, "strftime", "s", "'%d:%H:%M:%S'"); break; |
