Convert datetime to a string 'YYYY-MM-DD hh:mm:ss'. Open coded for better performance. This code previously resided in field.cc, in Field_timestamp::val_str(). @param to OUT The string pointer to print at. @param ltime The MYSQL_TIME value. @return The length of the result string. */
| 1259 | @return The length of the result string. |
| 1260 | */ |
| 1261 | static inline int |
| 1262 | TIME_to_datetime_str(char *to, const MYSQL_TIME *ltime) |
| 1263 | { |
| 1264 | uint32 temp, temp2; |
| 1265 | /* Year */ |
| 1266 | temp= ltime->year / 100; |
| 1267 | *to++= (char) ('0' + temp / 10); |
| 1268 | *to++= (char) ('0' + temp % 10); |
| 1269 | temp= ltime->year % 100; |
| 1270 | *to++= (char) ('0' + temp / 10); |
| 1271 | *to++= (char) ('0' + temp % 10); |
| 1272 | *to++= '-'; |
| 1273 | /* Month */ |
| 1274 | temp= ltime->month; |
| 1275 | temp2= temp / 10; |
| 1276 | temp= temp-temp2 * 10; |
| 1277 | *to++= (char) ('0' + (char) (temp2)); |
| 1278 | *to++= (char) ('0' + (char) (temp)); |
| 1279 | *to++= '-'; |
| 1280 | /* Day */ |
| 1281 | temp= ltime->day; |
| 1282 | temp2= temp / 10; |
| 1283 | temp= temp - temp2 * 10; |
| 1284 | *to++= (char) ('0' + (char) (temp2)); |
| 1285 | *to++= (char) ('0' + (char) (temp)); |
| 1286 | *to++= ' '; |
| 1287 | /* Hour */ |
| 1288 | temp= ltime->hour; |
| 1289 | temp2= temp / 10; |
| 1290 | temp= temp - temp2 * 10; |
| 1291 | *to++= (char) ('0' + (char) (temp2)); |
| 1292 | *to++= (char) ('0' + (char) (temp)); |
| 1293 | *to++= ':'; |
| 1294 | /* Minute */ |
| 1295 | temp= ltime->minute; |
| 1296 | temp2= temp / 10; |
| 1297 | temp= temp - temp2 * 10; |
| 1298 | *to++= (char) ('0' + (char) (temp2)); |
| 1299 | *to++= (char) ('0' + (char) (temp)); |
| 1300 | *to++= ':'; |
| 1301 | /* Second */ |
| 1302 | temp= ltime->second; |
| 1303 | temp2=temp / 10; |
| 1304 | temp= temp - temp2 * 10; |
| 1305 | *to++= (char) ('0' + (char) (temp2)); |
| 1306 | *to++= (char) ('0' + (char) (temp)); |
| 1307 | return 19; |
| 1308 | } |
| 1309 | |
| 1310 | |
| 1311 | /** |
no outgoing calls
no test coverage detected