summaryrefslogtreecommitdiff
path: root/psycopg
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2007-01-16 10:47:28 +0000
committerFederico Di Gregorio <fog@initd.org>2007-01-16 10:47:28 +0000
commitd342d37e27fc7b30112a7c629bc7f397d467791c (patch)
treecf244ac059193ff3057ee1b3316d5458e9ccfea2 /psycopg
parentb651781f6348a3d988287c335e4e762b5adb30d1 (diff)
downloadpsycopg2-d342d37e27fc7b30112a7c629bc7f397d467791c.tar.gz
Fixed problem with locales in mx.DateTime adaptation.
Diffstat (limited to 'psycopg')
-rw-r--r--psycopg/adapter_mxdatetime.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/psycopg/adapter_mxdatetime.c b/psycopg/adapter_mxdatetime.c
index 3fcd238..f437435 100644
--- a/psycopg/adapter_mxdatetime.c
+++ b/psycopg/adapter_mxdatetime.c
@@ -43,23 +43,22 @@ static PyObject *
mxdatetime_str(mxdatetimeObject *self)
{
PyObject *str = NULL, *res = NULL;
-
+ PyObject *supa, *supb;
+
switch (self->type) {
case PSYCO_MXDATETIME_DATE:
+ str = PyObject_GetAttrString(self->wrapped, "date");
+ break;
+
case PSYCO_MXDATETIME_TIMESTAMP:
- str = PyObject_Str(self->wrapped);
-
- /* given the limitation of the mx.DateTime module that uses the same
- type for both date and timestamp values we need to do some black
- magic and make sure we're not using an adapt()ed timestamp as a
- simple date */
- if (strncmp(&(PyString_AsString(str)[11]), "00:00:00.000", 12) == 0) {
- PyObject *tmp =
- PyString_FromStringAndSize(PyString_AsString(str), 10);
- Py_DECREF(str);
- str = tmp;
- }
+ /* here we build the right ISO string from date and time */
+ supa = PyObject_GetAttrString(self->wrapped, "date");
+ supb = PyObject_GetAttrString(self->wrapped, "time");
+ str = PyString_FromFormat("%sT%s",
+ PyString_AsString(supa), PyString_AsString(supb));
+ Py_XDECREF(supa);
+ Py_XDECREF(supb);
break;
case PSYCO_MXDATETIME_TIME: