Mercurial > urweb
comparison src/mysql.sml @ 938:6b1d960e2616
Fix MySQL timestamp input
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 15 Sep 2009 10:43:01 -0400 |
parents | 6a284a3519ba |
children | ad434669f299 |
comparison
equal
deleted
inserted
replaced
937:37dd42935dad | 938:6b1d960e2616 |
---|---|
47 case t of | 47 case t of |
48 Int => "MYSQL_TYPE_LONGLONG" | 48 Int => "MYSQL_TYPE_LONGLONG" |
49 | Float => "MYSQL_TYPE_DOUBLE" | 49 | Float => "MYSQL_TYPE_DOUBLE" |
50 | String => "MYSQL_TYPE_STRING" | 50 | String => "MYSQL_TYPE_STRING" |
51 | Bool => "MYSQL_TYPE_LONG" | 51 | Bool => "MYSQL_TYPE_LONG" |
52 | Time => "MYSQL_TYPE_TIME" | 52 | Time => "MYSQL_TYPE_TIMESTAMP" |
53 | Blob => "MYSQL_TYPE_BLOB" | 53 | Blob => "MYSQL_TYPE_BLOB" |
54 | Channel => "MYSQL_TYPE_LONGLONG" | 54 | Channel => "MYSQL_TYPE_LONGLONG" |
55 | Client => "MYSQL_TYPE_LONG" | 55 | Client => "MYSQL_TYPE_LONG" |
56 | Nullable t => p_buffer_type t | 56 | Nullable t => p_buffer_type t |
57 | 57 |
664 string "MYSQL_TIME *mt = &buffer", | 664 string "MYSQL_TIME *mt = &buffer", |
665 string (Int.toString i), | 665 string (Int.toString i), |
666 string ";", | 666 string ";", |
667 newline, | 667 newline, |
668 newline, | 668 newline, |
669 string "struct tm t = {mt->second, mt->minute, mt->hour, mt->day, mt->month-1, mt->year, 0, 0, -1};", | 669 string "struct tm t = {mt->second, mt->minute, mt->hour, mt->day, mt->month-1, mt->year - 1900, 0, 0, -1};", |
670 newline, | 670 newline, |
671 string "mktime(&t);", | 671 string "mktime(&t);", |
672 newline, | 672 newline, |
673 string "})"] | 673 string "})"] |
674 | Channel => box [string "({", | 674 | Channel => box [string "({", |
1056 string (Int.toString (i + 1)), | 1056 string (Int.toString (i + 1)), |
1057 string ", &tms) == NULL) uw_error(ctx, FATAL, \"", | 1057 string ", &tms) == NULL) uw_error(ctx, FATAL, \"", |
1058 string (ErrorMsg.spanToString loc), | 1058 string (ErrorMsg.spanToString loc), |
1059 string ": error converting to MySQL time\");", | 1059 string ": error converting to MySQL time\");", |
1060 newline, | 1060 newline, |
1061 oneField "year" "year", | 1061 oneField "year" "year + 1900", |
1062 box [string "in_buffer", | 1062 box [string "in_buffer", |
1063 string (Int.toString i), | 1063 string (Int.toString i), |
1064 string ".month = tms.tm_mon + 1;", | 1064 string ".month = tms.tm_mon + 1;", |
1065 newline], | 1065 newline], |
1066 oneField "day" "mday", | 1066 oneField "day" "mday", |
1067 oneField "hour" "hour", | 1067 oneField "hour" "hour - 1", |
1068 oneField "minute" "min", | 1068 oneField "minute" "min", |
1069 oneField "second" "sec", | 1069 oneField "second" "sec", |
1070 newline, | 1070 newline, |
1071 string "in[", | 1071 string "in[", |
1072 string (Int.toString i), | 1072 string (Int.toString i), |
1337 string (Int.toString (i + 1)), | 1337 string (Int.toString (i + 1)), |
1338 string ", &tms) == NULL) uw_error(ctx, FATAL, \"", | 1338 string ", &tms) == NULL) uw_error(ctx, FATAL, \"", |
1339 string (ErrorMsg.spanToString loc), | 1339 string (ErrorMsg.spanToString loc), |
1340 string ": error converting to MySQL time\");", | 1340 string ": error converting to MySQL time\");", |
1341 newline, | 1341 newline, |
1342 oneField "year" "year", | 1342 oneField "year" "year + 1900", |
1343 oneField "month" "mon", | 1343 oneField "month" "mon + 1", |
1344 oneField "day" "mday", | 1344 oneField "day" "mday", |
1345 oneField "hour" "hour", | 1345 oneField "hour" "hour - 1", |
1346 oneField "minute" "min", | 1346 oneField "minute" "min", |
1347 oneField "second" "sec", | 1347 oneField "second" "sec", |
1348 newline, | 1348 newline, |
1349 string "in[", | 1349 string "in[", |
1350 string (Int.toString i), | 1350 string (Int.toString i), |