diff src/c/urweb.c @ 2072:d77b0665ba7c

Default to parsing time strings with the application-configured format
author Adam Chlipala <adam@chlipala.net>
date Sat, 20 Sep 2014 13:55:25 -0400
parents a9159911c3ba
children 1839df6ed755 98b87d905601
line wrap: on
line diff
--- 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) {