From 417030f4fe6a722eb67b616fa1f025ed6439e74d Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 10 Aug 2020 21:50:40 +0100 Subject: [PATCH] Parse the YYYY-MM-DDTHH:MM:SSZ dates correctly Dates in the json reply seem to come in two different formats. One is the reply timestamp, second one is the actual content (for example shop opening dates) --- src/oro/dateconv.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/oro/dateconv.cpp b/src/oro/dateconv.cpp index ce62b79..3154bd7 100644 --- a/src/oro/dateconv.cpp +++ b/src/oro/dateconv.cpp @@ -46,8 +46,14 @@ namespace { //https://howardhinnant.github.io/date/date.html#from_stream_formatting Timestamp from_json_timestamp (const std::string& str) { - //date has this format: 2020-06-19T22:33:36.855672+00:00 - return to_timestamp("%FT%T%Ez", str); + if (not str.empty() and str.back() == 'Z') { + //date has this format: 2020-06-19T22:40:51Z + return to_timestamp("%FT%TZ", str); + } + else { + //date has this format: 2020-06-19T22:33:36.855672+00:00 + return to_timestamp("%FT%T%Ez", str); + } } Timestamp from_header_timestamp (const std::string& str) {