Mercurial > urweb
diff src/c/urweb.c @ 1364:0dec38af601c
Fix Postgres date serialization
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 24 Dec 2010 17:18:28 -0500 |
parents | 7dd8a6704265 |
children | b02cb9da5686 |
line wrap: on
line diff
--- a/src/c/urweb.c Fri Dec 24 16:41:10 2010 -0500 +++ b/src/c/urweb.c Fri Dec 24 17:18:28 2010 -0500 @@ -2513,7 +2513,7 @@ 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 @@ return "<Invalid time>"; } +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 "<Invalid time>"; +} + char *uw_Basis_sqlifyTimeN(uw_context ctx, uw_Basis_time *t) { if (t == NULL) return "NULL";