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)
This commit is contained in:
parent
9bb2efb2ee
commit
417030f4fe
1 changed files with 8 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue