From ee0704c539ddf46de2055e87f6e304b9b720515e Mon Sep 17 00:00:00 2001 From: Tomasz Golinski Date: Wed, 30 Aug 2023 15:10:54 +0200 Subject: [PATCH] Fix daylight saving problems std::get_time doesn't set daylight saving time information, it causes various problems with std::mktime later on causing drifts of +/- 1h --- okapi.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/okapi.cpp b/okapi.cpp index 7af3b82..21f89eb 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -184,6 +184,7 @@ Caches Okapi::get_caches(const std::set& codes) const { std::tm tmp; std::stringstream ss(el.value()["date_created"].get()); ss >> std::get_time(&tmp, "%Y-%m-%dT%H:%M:%S+"); + tmp.tm_isdst = -1; c.set_date_hidden(tmp); cc.push_back(c); @@ -216,6 +217,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const { std::stringstream ss(el.value()["date"].get()); // TODO need to take care of the time zone :/ ss >> std::get_time(&date, "%Y-%m-%dT%H:%M:%S+"); + date.tm_isdst = -1; codes.insert(el.value()["cache_code"].get()); tmp_data[el.value()["cache_code"].get()] = { date, el.value()["was_recommended"] }; } @@ -232,6 +234,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const { if (el.value()["type"] == "Found it") { std::stringstream ss(el.value()["date"].get()); ss >> std::get_time(&date, "%Y-%m-%dT%H-%M-%S"); + date.tm_isdst = -1; codes.insert(el.value()["cache_code"].get()); tmp_data[el.value()["cache_code"].get()] = { date, el.value()["was_recommended"] }; }