diff --git a/src/easy/entity.cpp b/src/easy/entity.cpp index db809f3..bee9bd9 100644 --- a/src/easy/entity.cpp +++ b/src/easy/entity.cpp @@ -14,10 +14,10 @@ * along with this program. If not, see . */ -#include #include // get_time #include #include +#include #include #include #include "easy/entity.hpp" @@ -233,9 +233,10 @@ const Easy::time Easy::Entity::get_time(const string &key) const if (node.isString()) { std::stringstream sstime(node.asString()); - struct std::tm tm; + struct std::tm tm = {}; + tm.tm_isdst = -1; // Detect daylight saving time. sstime >> std::get_time(&tm, "%Y-%m-%dT%T"); - std::time_t time = timegm(&tm); + std::time_t time = timegm(&tm); // Assume time is UTC. _was_set = true; return { system_clock::from_time_t(time) }; } diff --git a/src/easy/types_easy.cpp b/src/easy/types_easy.cpp index 2da051c..835d883 100644 --- a/src/easy/types_easy.cpp +++ b/src/easy/types_easy.cpp @@ -32,18 +32,18 @@ const string Easy::time::strtime(const string &format, const bool &local) const { constexpr std::uint16_t bufsize = 1024; std::time_t time = system_clock::to_time_t(timepoint); - std::tm *timeinfo; + std::tm *tm; if (local) { - timeinfo = std::localtime(&time); + tm = std::localtime(&time); } else { - timeinfo = std::gmtime(&time); + tm = std::gmtime(&time); } char buffer[bufsize]; - std::strftime(buffer, bufsize, format.c_str(), timeinfo); + std::strftime(buffer, bufsize, format.c_str(), tm); return static_cast(buffer); }