Mercurial > urweb
changeset 1443:19e8e3d556d6
Fix MySQL time handling
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 27 Mar 2011 15:06:02 -0400 |
parents | 204ca664b5d6 |
children | 0fc7b676b88b |
files | src/mysql.sml tests/urblog.ur tests/urblog.urp tests/urblog.urs |
diffstat | 4 files changed, 46 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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,
--- /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 => + <xml> + <div> + <h1>{[row.Entry.Title]}</h1><br /> + <h2>By {[row.Entry.Author]} at {[row.Entry.Created]}</h2> + <p>{[row.Entry.Body]}</p> + </div> + </xml> + ); + return + <xml> + <head> + <title>All Entries</title> + </head> + <body> + <h1>All Entries</h1> + {rows} + </body> + </xml> + +fun main () = return <xml> + <head> + <title>UrBlog</title> + </head> + + <body> + <h1>UrBlog</h1> + </body> +</xml>