From a6c580af25ee9e6112fcb116d9b0d2a09d2ea7cf Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 24 Dec 2010 17:18:28 -0500 Subject: Fix Postgres date serialization --- src/c/urweb.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/c/urweb.c') diff --git a/src/c/urweb.c b/src/c/urweb.c index 77d39ee7..4038c100 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -2513,7 +2513,7 @@ char *uw_Basis_sqlifyTime(uw_context ctx, uw_Basis_time t) { if (localtime_r(&t, &stm)) { s = uw_malloc(ctx, TIMES_MAX); - len = strftime(s, TIMES_MAX, TIME_FMT, &stm); + len = strftime(s, TIMES_MAX, TIME_FMT_PG, &stm); r = uw_malloc(ctx, len + 14); sprintf(r, "'%s'::timestamp", s); return r; @@ -2536,6 +2536,21 @@ char *uw_Basis_attrifyTime(uw_context ctx, uw_Basis_time t) { return ""; } +char *uw_Basis_ensqlTime(uw_context ctx, uw_Basis_time t) { + size_t len; + char *r; + struct tm stm; + + if (localtime_r(&t, &stm)) { + uw_check_heap(ctx, TIMES_MAX); + r = ctx->heap.front; + len = strftime(r, TIMES_MAX, TIME_FMT_PG, &stm); + ctx->heap.front += len+1; + return r; + } else + return ""; +} + char *uw_Basis_sqlifyTimeN(uw_context ctx, uw_Basis_time *t) { if (t == NULL) return "NULL"; -- cgit v1.2.3