Changeset 7768
- Timestamp:
- Jun 30, 2006, 1:50:56 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/db/psDB.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r7766 r7768 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.6 8$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-06-30 02:20:06 $14 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-06-30 23:50:56 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 972 972 psMetadataAdd(md, PS_LIST_TAIL, field[i].name, pType, "", atoi(data)); 973 973 } else if (pType == PS_DATA_TIME) { 974 psTime *time = psTimeStrptime((char *)data, "%EY-%m-%d%t%T"); 975 if (!time) { 976 psError(PS_ERR_UNKNOWN, true, "error parsing MySQL DateTime string"); 977 return NULL; 978 } 979 psMetadataAddTime(md, PS_LIST_TAIL, field[i].name, 0, "", time); 980 psFree(time); 981 #if 0 982 // this is the procedure needed for stmt 983 MYSQL_TIME *myTime = (MYSQL_TIME *)&data; 984 // convert MYSQL_TIME to struct tm 985 struct tm tmTime; 986 tmTime.tm_year = (int)myTime->year - 1900; 987 tmTime.tm_mon = (int)myTime->month - 1; 988 tmTime.tm_mday = (int)myTime->day; 989 tmTime.tm_hour = (int)myTime->hour; 990 tmTime.tm_min = (int)myTime->minute; 991 tmTime.tm_sec = (int)myTime->second; 992 // assume for the time being that we don't have negative time 993 //(bool)myTime->neg 994 // currently unused by mysql nor does struct tm support it 995 // (unsigned long)myTime->second_part; 996 psTime *time = psTimeFromTM(&tmTime); 974 997 psMetadataAddTime(md, PS_LIST_TAIL, field[i].name, 0, "", 975 psTimeFromISO(data, PS_TIME_UTC)); 998 time); 999 psFree(time); 1000 #endif 1001 976 1002 } else { 977 1003 // XXX: assume binary string ... … … 1075 1101 // try to do the conversion 1076 1102 if ((char *)item->data.V) { 1077 psTime *time = p_psTimeCopy((psTime *)item->data.V); 1078 psTimeConvert(time, PS_TIME_UTC); 1079 bind[i].buffer = psTimeToISO(time); 1080 psFree(time); 1081 bind[i].buffer_length = (unsigned long)strlen((char *)bind[i].buffer); 1103 psTime *time = (psTime *)item->data.V; 1104 struct tm *tmTime = psTimeToTM(time); 1105 1106 // XXX it wouldn't hurt to make this conversion it's own 1107 // function 1108 // myTime is used as the 'buffer' so it doesn't have to be 1109 // free'd 1110 MYSQL_TIME *myTime = psAlloc(sizeof(MYSQL_TIME)); 1111 myTime->year = (unsigned int)tmTime->tm_year + 1900; 1112 myTime->month = (unsigned int)tmTime->tm_mon + 1; 1113 myTime->day = (unsigned int)tmTime->tm_mday; 1114 myTime->hour = (unsigned int)tmTime->tm_hour; 1115 myTime->minute = (unsigned int)tmTime->tm_min; 1116 myTime->second = (unsigned int)tmTime->tm_sec; 1117 // assume for the time being that we don't have negative time 1118 // as ISO8601 doesn't support dates prior to 0 1119 myTime->neg = (my_bool)false; 1120 // currently unused by mysql 1121 myTime->second_part = (unsigned long)time->nsec; 1122 psFree(tmTime); 1123 1124 bind[i].buffer = myTime; 1125 bind[i].buffer_length = 0; 1082 1126 bind[i].length = &bind[i].buffer_length; 1083 1127 bind[i].is_null = NULL; … … 1162 1206 // find column name and type 1163 1207 while ((item = psListGetAndIncrement(cursor))) { 1164 if ((item->type == PS_DATA_S32) || (item->type == PS_DATA_F32) || (item->type == PS_DATA_F64) || 1165 (item->type == PS_TYPE_S32) || (item->type == PS_TYPE_F32) || (item->type == PS_TYPE_F64) || 1166 (item->type == PS_TYPE_BOOL) || (item->type == PS_DATA_BOOL)) { 1208 if ((item->type == PS_DATA_S32) 1209 || (item->type == PS_DATA_F32) 1210 || (item->type == PS_DATA_F64) 1211 || (item->type == PS_TYPE_S32) 1212 || (item->type == PS_TYPE_F32) 1213 || (item->type == PS_TYPE_F64) 1214 || (item->type == PS_TYPE_BOOL) 1215 || (item->type == PS_DATA_BOOL) 1216 || (item->type == PS_DATA_TIME) 1217 ) { 1167 1218 // + column name + _ + column type 1168 1219 colType = psDBPTypeToSQL(item->type);
Note:
See TracChangeset
for help on using the changeset viewer.
