From a167f651f6a12eab4772ab3cb16b63633e8c77ae Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 20 Sep 2014 13:55:25 -0400 Subject: Default to parsing time strings with the application-configured format --- src/c/urweb.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/c/urweb.c') diff --git a/src/c/urweb.c b/src/c/urweb.c index d7bc05e3..09514afa 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -2897,13 +2897,17 @@ uw_Basis_time *uw_Basis_stringToTime(uw_context ctx, uw_Basis_string s) { } } 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 @@ uw_Basis_time uw_Basis_stringToTime_error(uw_context ctx, uw_Basis_string s) { } } 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) { -- cgit v1.2.3