return -1;
}
-static json_object *time_to_json(time_t t)
+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)
static json_object *bpph_to_json(struct bpph *bpph)
{
- json_object *json;
+ json_object *json, *time;
json = json_object_new_object();
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;
}