Code

data: Double quote formatted date-times.
authorSebastian Harl <sh@tokkee.org>
Mon, 10 Feb 2014 18:12:49 +0000 (19:12 +0100)
committerSebastian Harl <sh@tokkee.org>
Mon, 10 Feb 2014 18:12:49 +0000 (19:12 +0100)
JSON does not support time values, thus, we need to treat this is a string.

src/core/data.c
t/core/data_test.c

index 735639dcc450f2761dbf0179a70a27d7de784c81..500a62293dbbdc44f53a1db64534554ea91540c0 100644 (file)
@@ -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:
index e4ead2fe12711484bd5f5c4a42d46076e989c29f..ebff6845df196a702870b781820f88e1050240db 100644 (file)
@@ -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);