change datetime parsing to use std::get_time for mac and android compat

This commit is contained in:
HJfod 2024-03-10 12:21:30 +02:00
parent be5e892cbe
commit e74e56e8ff

View file

@ -101,10 +101,11 @@ std::string ServerDateTime::toAgoString() const {
Result<ServerDateTime> ServerDateTime::parse(std::string const& str) {
std::stringstream ss(str);
Value value;
if (std::chrono::from_stream(ss, "%FT%TZ", value)) {
std::tm value;
if (ss >> std::get_time(&value, "%Y-%m-%dT%H:%M:%SZ")) {
auto time = std::mktime(&value);
return Ok(ServerDateTime {
.value = value,
.value = Clock::from_time_t(time),
});
}
return Err("Invalid date time format '{}'", str);