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