time/Parser: use TimeGm()

This commit is contained in:
Max Kellermann 2019-08-19 22:21:22 +02:00
parent b02890eb8a
commit fed9b6fd74
1 changed files with 3 additions and 4 deletions

View File

@ -28,6 +28,7 @@
*/ */
#include "Parser.hxx" #include "Parser.hxx"
#include "Convert.hxx"
#include "util/Compiler.h" #include "util/Compiler.h"
#include <stdexcept> #include <stdexcept>
@ -72,13 +73,11 @@ ParseTimePoint(const char *s, const char *format)
#ifdef __GLIBC__ #ifdef __GLIBC__
/* timegm() is a GNU extension */ /* timegm() is a GNU extension */
const auto t = timegm(&tm); return TimeGm(tm);
#else #else
tm.tm_isdst = 0; tm.tm_isdst = 0;
const auto t = mktime(&tm) + GetTimeZoneOffset(); const auto t = mktime(&tm) + GetTimeZoneOffset();
#endif /* !__GLIBC__ */
return std::chrono::system_clock::from_time_t(t); return std::chrono::system_clock::from_time_t(t);
#endif /* !__GLIBC__ */
#endif /* !_WIN32 */ #endif /* !_WIN32 */
} }