Treat datetime objects as actual datetime objects
This commit is contained in:
parent
9d15a0f2f7
commit
7655cefedd
@ -64,7 +64,51 @@ void build::parse_json(const std::string& json_data) {
|
||||
{"changesfile_url", [this](const nlohmann::json& val) { changesfile_url = val.get<std::string>(); }},
|
||||
{"buildinfo_url", [this](const nlohmann::json& val) { buildinfo_url = 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) {
|
||||
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");
|
||||
if (ss.fail()) {
|
||||
std::cout << val << std::endl;
|
||||
throw std::runtime_error("Failed to parse date_first_dispatched");
|
||||
}
|
||||
date_first_dispatched = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
}},
|
||||
{"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");
|
||||
if (ss.fail()) {
|
||||
std::cout << val << std::endl;
|
||||
throw std::runtime_error("Failed to parse date_started");
|
||||
}
|
||||
date_started = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
}},
|
||||
{"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");
|
||||
if (ss.fail()) {
|
||||
std::cout << val << std::endl;
|
||||
throw std::runtime_error("Failed to parse datebuilt");
|
||||
}
|
||||
datebuilt = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
}},
|
||||
{"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");
|
||||
if (ss.fail()) {
|
||||
std::cout << val << std::endl;
|
||||
throw std::runtime_error("Failed to parse datecreated");
|
||||
}
|
||||
datecreated = std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
}}
|
||||
};
|
||||
|
||||
// Process JSON keys
|
||||
|
@ -74,10 +74,10 @@ public:
|
||||
std::string source_package_name;
|
||||
std::string source_package_version;
|
||||
std::string web_link;
|
||||
std::string date_first_dispatched;
|
||||
std::string date_started;
|
||||
std::string datebuilt;
|
||||
std::string datecreated;
|
||||
std::chrono::system_clock::time_point date_first_dispatched;
|
||||
std::chrono::system_clock::time_point date_started;
|
||||
std::chrono::system_clock::time_point datebuilt;
|
||||
std::chrono::system_clock::time_point datecreated;
|
||||
|
||||
// Object collections
|
||||
std::optional<source_package_publishing_history> current_source_publication = getCurrentSourcePublication();
|
||||
|
Loading…
x
Reference in New Issue
Block a user