From 633272632f6618c2363a615ea766cec956396118 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 10 Feb 2014 19:12:49 +0100 Subject: [PATCH] data: Double quote formatted date-times. JSON does not support time values, thus, we need to treat this is a string. --- src/core/data.c | 2 +- t/core/data_test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/data.c b/src/core/data.c index 735639d..500a622 100644 --- a/src/core/data.c +++ b/src/core/data.c @@ -109,7 +109,7 @@ sdb_data_format(sdb_data_t *datum, sdb_strbuf_t *buf) datum->data.datetime)) return -1; tmp[sizeof(tmp) - 1] = '\0'; - sdb_strbuf_append(buf, "%s", tmp); + sdb_strbuf_append(buf, "\"%s\"", tmp); } break; case SDB_TYPE_BINARY: diff --git a/t/core/data_test.c b/t/core/data_test.c index e4ead2f..ebff684 100644 --- a/t/core/data_test.c +++ b/t/core/data_test.c @@ -162,7 +162,7 @@ START_TEST(test_format) fail_unless(! check, "sdb_data_format(DATETIME) = %d; expected: 0", check); string = sdb_strbuf_string(buf); - expected = "1984-12-06 02:11:54 +0000"; + expected = "\"1984-12-06 02:11:54 +0000\""; fail_unless(! strcmp(string, expected), "sdb_data_format() used wrong format: %s; expected: %s", string, expected); -- 2.30.2