From c7864ae5dc5d26fd07896f913dbc79d10bdec017 Mon Sep 17 00:00:00 2001 From: gabime Date: Wed, 6 Jan 2016 21:30:42 +0200 Subject: [PATCH] throw exception if DYNAMIC_TIME_ZONE_INFORMATION fails under windows instead of returning -1 --- include/spdlog/details/os.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index bbf84225..30e2f6d9 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -165,7 +165,7 @@ inline bool file_exists(const std::string& filename) } -//Return utc offset in minutes or -1 on failure +//Return utc offset in minutes or throw spdlog_ex on failure inline int utc_minutes_offset(const std::tm& tm = details::os::localtime()) { @@ -178,7 +178,8 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime()) auto rv = GetDynamicTimeZoneInformation(&tzinfo); #endif if (rv == TIME_ZONE_ID_INVALID) - return -1; + throw spdlog::spdlog_ex("Failed getting timezone info. Last error: " + GetLastError()); + int offset = -tzinfo.Bias; if (tm.tm_isdst) offset -= tzinfo.DaylightBias;