Index: /trunk/psLib/src/db/psDB.c
===================================================================
--- /trunk/psLib/src/db/psDB.c	(revision 7767)
+++ /trunk/psLib/src/db/psDB.c	(revision 7768)
@@ -12,6 +12,6 @@
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-30 02:20:06 $
+ *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-06-30 23:50:56 $
  *
  *  Copyright 2005 Joshua Hoblitt, University of Hawaii
@@ -972,6 +972,32 @@
                 psMetadataAdd(md, PS_LIST_TAIL, field[i].name, pType, "", atoi(data));
             } else if (pType == PS_DATA_TIME) {
+                psTime *time = psTimeStrptime((char *)data, "%EY-%m-%d%t%T");
+                if (!time) {
+                    psError(PS_ERR_UNKNOWN, true, "error parsing MySQL DateTime string");
+                    return NULL;
+                }
+                psMetadataAddTime(md, PS_LIST_TAIL, field[i].name, 0, "", time);
+                psFree(time);
+                #if 0
+                // this is the procedure needed for stmt
+                MYSQL_TIME *myTime = (MYSQL_TIME *)&data;
+                // convert MYSQL_TIME to struct tm
+                struct tm tmTime;
+                tmTime.tm_year  = (int)myTime->year - 1900;
+                tmTime.tm_mon   = (int)myTime->month - 1;
+                tmTime.tm_mday  = (int)myTime->day;
+                tmTime.tm_hour  = (int)myTime->hour;
+                tmTime.tm_min   = (int)myTime->minute;
+                tmTime.tm_sec   = (int)myTime->second;
+                // assume for the time being that we don't have negative time
+                //(bool)myTime->neg
+                // currently unused by mysql nor does struct tm support it
+                // (unsigned long)myTime->second_part;
+                psTime *time = psTimeFromTM(&tmTime);
                 psMetadataAddTime(md, PS_LIST_TAIL, field[i].name, 0, "",
-                                  psTimeFromISO(data, PS_TIME_UTC));
+                                  time);
+                psFree(time);
+                #endif
+
             } else {
                 // XXX: assume binary string ...
@@ -1075,9 +1101,27 @@
             // try to do the conversion
             if ((char *)item->data.V) {
-                psTime *time = p_psTimeCopy((psTime *)item->data.V);
-                psTimeConvert(time, PS_TIME_UTC);
-                bind[i].buffer  = psTimeToISO(time);
-                psFree(time);
-                bind[i].buffer_length = (unsigned long)strlen((char *)bind[i].buffer);
+                psTime *time = (psTime *)item->data.V;
+                struct tm *tmTime = psTimeToTM(time);
+
+                // XXX it wouldn't hurt to make this conversion it's own
+                // function
+                // myTime is used as the 'buffer' so it doesn't have to be
+                // free'd
+                MYSQL_TIME *myTime = psAlloc(sizeof(MYSQL_TIME));
+                myTime->year    = (unsigned int)tmTime->tm_year + 1900;
+                myTime->month   = (unsigned int)tmTime->tm_mon + 1;
+                myTime->day     = (unsigned int)tmTime->tm_mday;
+                myTime->hour    = (unsigned int)tmTime->tm_hour;
+                myTime->minute  = (unsigned int)tmTime->tm_min;
+                myTime->second  = (unsigned int)tmTime->tm_sec;
+                // assume for the time being that we don't have negative time
+                // as ISO8601 doesn't support dates prior to 0
+                myTime->neg     = (my_bool)false;
+                // currently unused by mysql
+                myTime->second_part  = (unsigned long)time->nsec;
+                psFree(tmTime);
+
+                bind[i].buffer  = myTime;
+                bind[i].buffer_length = 0;
                 bind[i].length  = &bind[i].buffer_length;
                 bind[i].is_null = NULL;
@@ -1162,7 +1206,14 @@
     // find column name and type
     while ((item = psListGetAndIncrement(cursor))) {
-        if ((item->type == PS_DATA_S32)  || (item->type == PS_DATA_F32) || (item->type == PS_DATA_F64) ||
-                (item->type == PS_TYPE_S32)  || (item->type == PS_TYPE_F32) || (item->type == PS_TYPE_F64) ||
-                (item->type == PS_TYPE_BOOL) || (item->type == PS_DATA_BOOL)) {
+        if ((item->type == PS_DATA_S32)
+                || (item->type == PS_DATA_F32)
+                || (item->type == PS_DATA_F64)
+                || (item->type == PS_TYPE_S32)
+                || (item->type == PS_TYPE_F32)
+                || (item->type == PS_TYPE_F64)
+                || (item->type == PS_TYPE_BOOL)
+                || (item->type == PS_DATA_BOOL)
+                || (item->type == PS_DATA_TIME)
+           ) {
             // + column name + _ + column type
             colType = psDBPTypeToSQL(item->type);
