+/* Declares json_bool to have consistent code even with
+ old json lib releases using boolean instead of json_bool.*/
+#ifndef json_bool
+typedef boolean json_bool;
+#endif
+
+static time_t json_to_time(json_object *json)
+{
+ const char *str;
+ struct tm tm;
+ char *ret;
+
+ str = json_object_get_string(json);
+ if (!str)
+ return -1;
+
+ tm.tm_isdst = -1;
+ ret = strptime(str, "%FT%T", &tm);
+
+ if (ret)
+ return mktime(&tm);
+ else
+ return -1;
+}
+
+static json_object *time_to_json(time_t t)
+{
+ char *str;
+
+ str = time_to_str(t);
+
+ if (str)
+ return json_object_new_string(str);
+ else
+ return NULL;
+}
+