# HG changeset patch # User Adam Chlipala # Date 1301252762 14400 # Node ID 19e8e3d556d6a45a6c24b398f6d14fe549b65819 # Parent 204ca664b5d672fc6b52030cdec42b7805c06729 Fix MySQL time handling diff -r 204ca664b5d6 -r 19e8e3d556d6 src/mysql.sml --- a/src/mysql.sml Sat Mar 26 13:43:47 2011 -0400 +++ b/src/mysql.sml Sun Mar 27 15:06:02 2011 -0400 @@ -675,7 +675,9 @@ newline, 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);", + string "uw_Basis_time res = {mktime(&t), 0};", + newline, + string "res;", newline, string "})"] | Channel => box [string "({", @@ -1082,7 +1084,7 @@ newline, string "if (localtime_r(&arg", string (Int.toString (i + 1)), - string ", &tms) == NULL) uw_error(ctx, FATAL, \"", + string ".seconds, &tms) == NULL) uw_error(ctx, FATAL, \"", string (ErrorMsg.spanToString loc), string ": error converting to MySQL time\");", newline, @@ -1366,7 +1368,7 @@ newline, string "if (localtime_r(&arg", string (Int.toString (i + 1)), - string ", &tms) == NULL) uw_error(ctx, FATAL, \"", + string ".seconds, &tms) == NULL) uw_error(ctx, FATAL, \"", string (ErrorMsg.spanToString loc), string ": error converting to MySQL time\");", newline, diff -r 204ca664b5d6 -r 19e8e3d556d6 tests/urblog.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/urblog.ur Sun Mar 27 15:06:02 2011 -0400 @@ -0,0 +1,35 @@ +table entry : { Id : int, Title : string, Created : time, Author : string, +Body : string } + PRIMARY KEY Id + +fun list () = + rows <- queryX (SELECT * FROM entry) + (fn row => + +
+

{[row.Entry.Title]}


+

By {[row.Entry.Author]} at {[row.Entry.Created]}

+

{[row.Entry.Body]}

+
+
+ ); + return + + + All Entries + + +

All Entries

+ {rows} + +
+ +fun main () = return + + UrBlog + + + +

UrBlog

+ +
diff -r 204ca664b5d6 -r 19e8e3d556d6 tests/urblog.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/urblog.urp Sun Mar 27 15:06:02 2011 -0400 @@ -0,0 +1,4 @@ +database dbname=urblog +sql urblog.sql + +urblog diff -r 204ca664b5d6 -r 19e8e3d556d6 tests/urblog.urs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/urblog.urs Sun Mar 27 15:06:02 2011 -0400 @@ -0,0 +1,2 @@ +val list : unit -> transaction page +val main : unit -> transaction page