time/Parser: explicitly initialize struct tm before strptime()

This is recommended by the strptime() manpage, because strptime() does
not initialize/set attributes which were not specified in the format
string.
This commit is contained in:
Max Kellermann 2019-08-19 22:09:38 +02:00
parent da882a6eb6
commit b02890eb8a

View File

@ -65,7 +65,7 @@ ParseTimePoint(const char *s, const char *format)
(void)format; (void)format;
throw std::runtime_error("Time parsing not implemented on Windows"); throw std::runtime_error("Time parsing not implemented on Windows");
#else #else
struct tm tm; struct tm tm{};
const char *end = strptime(s, format, &tm); const char *end = strptime(s, format, &tm);
if (end == nullptr || *end != 0) if (end == nullptr || *end != 0)
throw std::runtime_error("Failed to parse time stamp"); throw std::runtime_error("Failed to parse time stamp");