comparison 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
comparison
equal deleted inserted replaced
2071:739172204214 2072:d77b0665ba7c
2895 *dot = '.'; 2895 *dot = '.';
2896 return NULL; 2896 return NULL;
2897 } 2897 }
2898 } 2898 }
2899 else { 2899 else {
2900 if (strptime(s, TIME_FMT_PG, &stm) == end) { 2900 if (strptime(s, ctx->app->time_format, &stm) == end) {
2901 uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time)); 2901 uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time));
2902 r->seconds = mktime(&stm); 2902 r->seconds = mktime(&stm);
2903 r->microseconds = 0; 2903 r->microseconds = 0;
2904 return r; 2904 return r;
2905 } 2905 } else if (strptime(s, TIME_FMT_PG, &stm) == end) {
2906 else if (strptime(s, TIME_FMT, &stm) == end) { 2906 uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time));
2907 r->seconds = mktime(&stm);
2908 r->microseconds = 0;
2909 return r;
2910 } else if (strptime(s, TIME_FMT, &stm) == end) {
2907 uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time)); 2911 uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time));
2908 r->seconds = mktime(&stm); 2912 r->seconds = mktime(&stm);
2909 r->microseconds = 0; 2913 r->microseconds = 0;
2910 return r; 2914 return r;
2911 } else if (strptime(s, TIME_FMT_JS, &stm) == end) { 2915 } else if (strptime(s, TIME_FMT_JS, &stm) == end) {
3045 *dot = '.'; 3049 *dot = '.';
3046 uw_error(ctx, FATAL, "Can't parse time: %s", uw_Basis_htmlifyString(ctx, s)); 3050 uw_error(ctx, FATAL, "Can't parse time: %s", uw_Basis_htmlifyString(ctx, s));
3047 } 3051 }
3048 } 3052 }
3049 else { 3053 else {
3050 if (strptime(s, TIME_FMT_PG, &stm) == end) { 3054 if (strptime(s, ctx->app->time_format, &stm) == end) {
3055 uw_Basis_time r = { mktime(&stm) };
3056 return r;
3057 } else if (strptime(s, TIME_FMT_PG, &stm) == end) {
3051 uw_Basis_time r = { mktime(&stm) }; 3058 uw_Basis_time r = { mktime(&stm) };
3052 return r; 3059 return r;
3053 } else if (strptime(s, TIME_FMT, &stm) == end) { 3060 } else if (strptime(s, TIME_FMT, &stm) == end) {
3054 uw_Basis_time r = { mktime(&stm) }; 3061 uw_Basis_time r = { mktime(&stm) };
3055 return r; 3062 return r;