# HG changeset patch # User Adam Chlipala # Date 1411235725 14400 # Node ID d77b0665ba7cde57cbc57acad1369805011fd967 # Parent 7391722042142e75cbbea212cc8526b98ecf90fa Default to parsing time strings with the application-configured format diff -r 739172204214 -r d77b0665ba7c src/c/urweb.c --- a/src/c/urweb.c Tue Sep 02 17:42:10 2014 +0000 +++ b/src/c/urweb.c Sat Sep 20 13:55:25 2014 -0400 @@ -2897,13 +2897,17 @@ } } else { - if (strptime(s, TIME_FMT_PG, &stm) == end) { + if (strptime(s, ctx->app->time_format, &stm) == end) { uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time)); r->seconds = mktime(&stm); r->microseconds = 0; return r; - } - else if (strptime(s, TIME_FMT, &stm) == end) { + } else if (strptime(s, TIME_FMT_PG, &stm) == end) { + uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time)); + r->seconds = mktime(&stm); + r->microseconds = 0; + return r; + } else if (strptime(s, TIME_FMT, &stm) == end) { uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time)); r->seconds = mktime(&stm); r->microseconds = 0; @@ -3047,7 +3051,10 @@ } } else { - if (strptime(s, TIME_FMT_PG, &stm) == end) { + if (strptime(s, ctx->app->time_format, &stm) == end) { + uw_Basis_time r = { mktime(&stm) }; + return r; + } else if (strptime(s, TIME_FMT_PG, &stm) == end) { uw_Basis_time r = { mktime(&stm) }; return r; } else if (strptime(s, TIME_FMT, &stm) == end) { diff -r 739172204214 -r d77b0665ba7c tests/timeRoundTrip.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/timeRoundTrip.ur Sat Sep 20 13:55:25 2014 -0400 @@ -0,0 +1,3 @@ +fun main () : transaction page = + t <- now; + return {[readError (show t) : time]}