X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flp_json.c;h=8b025f78b0dd78b0d79f03eb106e7858c6ff502e;hb=55ffa21bfedade5cc1702622855277b860f0a7f3;hp=c3345fdbdee17b8a92869a3e8ce9c45c84fa94f9;hpb=9a8af404ffbfb331575dc4b37b044d49d728be8b;p=ppastats.git diff --git a/src/lp_json.c b/src/lp_json.c index c3345fd..8b025f7 100644 --- a/src/lp_json.c +++ b/src/lp_json.c @@ -25,6 +25,7 @@ #include "lp_json.h" #include "lp_ws.h" +#include static time_t json_to_time(json_object *json) { @@ -50,13 +51,17 @@ static time_t json_to_time(json_object *json) static json_object *time_to_json(time_t t) { char *str; + json_object *j; - str = time_to_str(t); + str = time_to_ISO8601_time(&t); - if (str) - return json_object_new_string(str); - else + if (str) { + j = json_object_new_string(str); + free(str); + return j; + } else { return NULL; + } } static struct bpph *json_to_bpph(json_object *o) @@ -102,7 +107,7 @@ static struct bpph *json_to_bpph(json_object *o) static json_object *bpph_to_json(struct bpph *bpph) { - json_object *json; + json_object *json, *time; json = json_object_new_object(); @@ -132,8 +137,9 @@ static json_object *bpph_to_json(struct bpph *bpph) json_object_object_add (json, "status", json_object_new_string(bpph->status)); + time = time_to_json(bpph->date_created); json_object_object_add - (json, "date_created", time_to_json(bpph->date_created)); + (json, "date_created", time); return json; }