mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 18:41:35 +08:00
throw exception if DYNAMIC_TIME_ZONE_INFORMATION fails under windows instead of returning -1
This commit is contained in:
parent
7a813078aa
commit
c7864ae5dc
@ -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())
|
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);
|
auto rv = GetDynamicTimeZoneInformation(&tzinfo);
|
||||||
#endif
|
#endif
|
||||||
if (rv == TIME_ZONE_ID_INVALID)
|
if (rv == TIME_ZONE_ID_INVALID)
|
||||||
return -1;
|
throw spdlog::spdlog_ex("Failed getting timezone info. Last error: " + GetLastError());
|
||||||
|
|
||||||
int offset = -tzinfo.Bias;
|
int offset = -tzinfo.Bias;
|
||||||
if (tm.tm_isdst)
|
if (tm.tm_isdst)
|
||||||
offset -= tzinfo.DaylightBias;
|
offset -= tzinfo.DaylightBias;
|
||||||
|
Loading…
Reference in New Issue
Block a user