|
|
|
@ -17,6 +17,7 @@
|
|
|
|
|
#include "source_package_publishing_history.h"
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
#include "launchpad.h"
|
|
|
|
|
#include <date/date.h>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
#include <regex>
|
|
|
|
@ -66,48 +67,48 @@ void build::parse_json(const std::string& json_data) {
|
|
|
|
|
{"external_dependencies", [this](const nlohmann::json& val) { external_dependencies = val.get<std::string>(); }},
|
|
|
|
|
{"pocket", [this](const nlohmann::json& val) { pocket = val.get<std::string>(); }},
|
|
|
|
|
{"date_first_dispatched", [this](const nlohmann::json& val) {
|
|
|
|
|
std::string datetimeStr = val.get<std::string>();
|
|
|
|
|
std::istringstream ss(datetimeStr);
|
|
|
|
|
std::tm tm = {};
|
|
|
|
|
ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S.%f%z");
|
|
|
|
|
std::chrono::sys_time<std::chrono::microseconds> parsed_time;
|
|
|
|
|
std::istringstream ss(val.get<std::string>());
|
|
|
|
|
ss >> date::parse("%FT%T%z", parsed_time);
|
|
|
|
|
|
|
|
|
|
if (ss.fail()) {
|
|
|
|
|
std::cout << val << std::endl;
|
|
|
|
|
throw std::runtime_error("Failed to parse date_first_dispatched");
|
|
|
|
|
throw std::runtime_error("Failed to parse date_first_dispatched: " + val.get<std::string>());
|
|
|
|
|
}
|
|
|
|
|
date_first_dispatched = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
|
|
|
|
|
|
|
|
|
date_first_dispatched = std::chrono::time_point_cast<std::chrono::system_clock::duration>(parsed_time);
|
|
|
|
|
}},
|
|
|
|
|
{"date_started", [this](const nlohmann::json& val) {
|
|
|
|
|
std::string datetimeStr = val.get<std::string>();
|
|
|
|
|
std::istringstream ss(datetimeStr);
|
|
|
|
|
std::tm tm = {};
|
|
|
|
|
ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S.%f%z");
|
|
|
|
|
std::chrono::sys_time<std::chrono::microseconds> parsed_time;
|
|
|
|
|
std::istringstream ss(val.get<std::string>());
|
|
|
|
|
ss >> date::parse("%FT%T%z", parsed_time);
|
|
|
|
|
|
|
|
|
|
if (ss.fail()) {
|
|
|
|
|
std::cout << val << std::endl;
|
|
|
|
|
throw std::runtime_error("Failed to parse date_started");
|
|
|
|
|
throw std::runtime_error("Failed to parse date_started: " + val.get<std::string>());
|
|
|
|
|
}
|
|
|
|
|
date_started = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
|
|
|
|
|
|
|
|
|
date_started = std::chrono::time_point_cast<std::chrono::system_clock::duration>(parsed_time);
|
|
|
|
|
}},
|
|
|
|
|
{"datebuilt", [this](const nlohmann::json& val) {
|
|
|
|
|
std::string datetimeStr = val.get<std::string>();
|
|
|
|
|
std::istringstream ss(datetimeStr);
|
|
|
|
|
std::tm tm = {};
|
|
|
|
|
ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S.%f%z");
|
|
|
|
|
std::chrono::sys_time<std::chrono::microseconds> parsed_time;
|
|
|
|
|
std::istringstream ss(val.get<std::string>());
|
|
|
|
|
ss >> date::parse("%FT%T%z", parsed_time);
|
|
|
|
|
|
|
|
|
|
if (ss.fail()) {
|
|
|
|
|
std::cout << val << std::endl;
|
|
|
|
|
throw std::runtime_error("Failed to parse datebuilt");
|
|
|
|
|
throw std::runtime_error("Failed to parse datebuilt: " + val.get<std::string>());
|
|
|
|
|
}
|
|
|
|
|
datebuilt = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
|
|
|
|
|
|
|
|
|
datebuilt = std::chrono::time_point_cast<std::chrono::system_clock::duration>(parsed_time);
|
|
|
|
|
}},
|
|
|
|
|
{"datecreated", [this](const nlohmann::json& val) {
|
|
|
|
|
std::string datetimeStr = val.get<std::string>();
|
|
|
|
|
std::istringstream ss(datetimeStr);
|
|
|
|
|
std::tm tm = {};
|
|
|
|
|
ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S.%f%z");
|
|
|
|
|
std::chrono::sys_time<std::chrono::microseconds> parsed_time;
|
|
|
|
|
std::istringstream ss(val.get<std::string>());
|
|
|
|
|
ss >> date::parse("%FT%T%z", parsed_time);
|
|
|
|
|
|
|
|
|
|
if (ss.fail()) {
|
|
|
|
|
std::cout << val << std::endl;
|
|
|
|
|
throw std::runtime_error("Failed to parse datecreated");
|
|
|
|
|
throw std::runtime_error("Failed to parse datecreated: " + val.get<std::string>());
|
|
|
|
|
}
|
|
|
|
|
datecreated = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
|
|
|
|
|
|
|
|
|
datecreated = std::chrono::time_point_cast<std::chrono::system_clock::duration>(parsed_time);
|
|
|
|
|
}}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|