- return bpph_new(binary_package_name,
- binary_package_version,
- distro_arch_series_link,
- self_link,
- architecture_specific);
+ bpph = bpph_new(binary_package_name,
+ binary_package_version,
+ distro_arch_series_link,
+ self_link,
+ architecture_specific);
+
+ date_created = json_object_get_string
+ (json_object_object_get(o, "date_created"));
+ if (date_created) {
+ bpph->date_created.tm_isdst = -1;
+ strptime(date_created, "%FT%T%z", &bpph->date_created);
+ }
+
+ return bpph;
+}
+
+static json_object *bpph_to_json(struct bpph *bpph)
+{
+ json_object *json;
+ char *date;
+
+ json = json_object_new_object();
+
+ json_object_object_add
+ (json,
+ "binary_package_name",
+ json_object_new_string(bpph->binary_package_name));
+
+ json_object_object_add
+ (json,
+ "binary_package_version",
+ json_object_new_string(bpph->binary_package_version));
+
+ json_object_object_add
+ (json,
+ "distro_arch_series_link",
+ json_object_new_string(bpph->distro_arch_series_link));
+
+ json_object_object_add
+ (json,
+ "architecture_specific",
+ json_object_new_boolean(bpph->architecture_specific));
+
+ date = malloc(strlen("YY-MM-DDThh:mm:ss+xxx") + 1);
+ strftime(date,
+ strlen("YY-MM-DDThh:mm:ss+xxx") + 1,
+ "%FT%T%z",
+ &bpph->date_created);
+
+ json_object_object_add
+ (json,
+ "date_created",
+ json_object_new_string(date));
+
+ free(date);
+
+ return json;