changeset 938:6b1d960e2616

Fix MySQL timestamp input
author Adam Chlipala <adamc@hcoop.net>
date Tue, 15 Sep 2009 10:43:01 -0400 (2009-09-15)
parents 37dd42935dad
children 38a376dc7401
files src/mysql.sml
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/mysql.sml	Tue Sep 15 10:18:56 2009 -0400
+++ b/src/mysql.sml	Tue Sep 15 10:43:01 2009 -0400
@@ -49,7 +49,7 @@
       | Float => "MYSQL_TYPE_DOUBLE"
       | String => "MYSQL_TYPE_STRING"
       | Bool => "MYSQL_TYPE_LONG"
-      | Time => "MYSQL_TYPE_TIME"
+      | Time => "MYSQL_TYPE_TIMESTAMP"
       | Blob => "MYSQL_TYPE_BLOB"
       | Channel => "MYSQL_TYPE_LONGLONG"
       | Client => "MYSQL_TYPE_LONG"
@@ -666,7 +666,7 @@
                              string ";",
                              newline,
                              newline,
-                             string "struct tm t = {mt->second, mt->minute, mt->hour, mt->day, mt->month-1, mt->year, 0, 0, -1};",
+                             string "struct tm t = {mt->second, mt->minute, mt->hour, mt->day, mt->month-1, mt->year - 1900, 0, 0, -1};",
                              newline,
                              string "mktime(&t);",
                              newline,
@@ -1058,13 +1058,13 @@
                                                                string (ErrorMsg.spanToString loc),
                                                                string ": error converting to MySQL time\");",
                                                                newline,
-                                                               oneField "year" "year",
+                                                               oneField "year" "year + 1900",
                                                                box [string "in_buffer",
                                                                     string (Int.toString i),
                                                                     string ".month = tms.tm_mon + 1;",
                                                                     newline],
                                                                oneField "day" "mday",
-                                                               oneField "hour" "hour",
+                                                               oneField "hour" "hour - 1",
                                                                oneField "minute" "min",
                                                                oneField "second" "sec",
                                                                newline,
@@ -1339,10 +1339,10 @@
                                                                string (ErrorMsg.spanToString loc),
                                                                string ": error converting to MySQL time\");",
                                                                newline,
-                                                               oneField "year" "year",
-                                                               oneField "month" "mon",
+                                                               oneField "year" "year + 1900",
+                                                               oneField "month" "mon + 1",
                                                                oneField "day" "mday",
-                                                               oneField "hour" "hour",
+                                                               oneField "hour" "hour - 1",
                                                                oneField "minute" "min",
                                                                oneField "second" "sec",
                                                                newline,