diff --git a/CMakeLists.txt b/CMakeLists.txt index d68c8e6..f3cea87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.2) project(gitea2rss - VERSION 0.3.0 + VERSION 0.3.1 LANGUAGES CXX ) diff --git a/src/main.cpp b/src/main.cpp index 08d92ef..9e7b776 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,10 +90,10 @@ const string strtime(const system_clock::time_point &timepoint) { constexpr uint16_t bufsize = 1024; std::time_t time = system_clock::to_time_t(timepoint); - std::tm *timeinfo; - timeinfo = std::localtime(&time); + std::tm *tm; + tm = std::gmtime(&time); char buffer[bufsize]; - std::strftime(buffer, bufsize, "%a, %d %b %Y %T %z", timeinfo); + std::strftime(buffer, bufsize, "%a, %d %b %Y %T %z", tm); return static_cast(buffer); } @@ -101,9 +101,10 @@ const string strtime(const system_clock::time_point &timepoint) const string strtime(const string &time) { std::tm tm = {}; + tm.tm_isdst = -1; // Detect daylight saving time. std::stringstream ss(time); - ss >> std::get_time(&tm, "%Y-%m-%dT%T%z"); - return strtime(std::chrono::system_clock::from_time_t(std::mktime(&tm))); + ss >> std::get_time(&tm, "%Y-%m-%dT%T"); // Assume time is UTC. + return strtime(std::chrono::system_clock::from_time_t(timegm(&tm))); } void write_line(const uint8_t spaces, const string &tag, const string &value)