mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 03:15:38 -05:00
change datetime parsing to use std::get_time for mac and android compat
This commit is contained in:
parent
be5e892cbe
commit
e74e56e8ff
1 changed files with 4 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue