/*
- * Copyright (C) 2011-2012 jeanfi@gmail.com
+ * Copyright (C) 2011-2014 jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
if (!str)
return -1;
+
+ memset(&tm, 0, sizeof(struct tm));
tm.tm_isdst = -1;
ret = strptime(str, "%FT%T", &tm);
const char *display_name;
const char *title;
const char *architecture_tag;
- boolean is_nominated_arch_indep;
+ json_bool is_nominated_arch_indep;
const char *distroseries_link;
display_name = json_object_get_string
result = malloc(sizeof(struct daily_download_total));
result->count = json_object_get_int(o_c);
+ memset(&result->date, 0, sizeof(struct tm));
strptime(d, "%FT%T%z", &result->date);
return result;
return result;
}
+
+struct json_object *date_to_json(struct tm *tm)
+{
+ json_object *json;
+
+ json = json_object_new_array();
+ json_object_array_add(json, json_object_new_int(tm->tm_year+1900));
+ json_object_array_add(json, json_object_new_int(tm->tm_mon+1));
+ json_object_array_add(json, json_object_new_int(tm->tm_mday));
+
+ return json;
+}
+
+json_object *ddts_to_json(struct daily_download_total **ddts)
+{
+ json_object *json_ddt, *json_ddts;
+ struct daily_download_total *ddt;
+
+ json_ddts = json_object_new_array();
+
+ while (ddts && *ddts) {
+ ddt = *ddts;
+
+ json_ddt = json_object_new_object();
+ json_object_object_add(json_ddt,
+ "value",
+ json_object_new_int(ddt->count));
+ json_object_object_add(json_ddt,
+ "time",
+ date_to_json(&ddt->date));
+
+ json_object_array_add(json_ddts, json_ddt);
+
+ ddts++;
+ }
+
+ return json_ddts;
+}