Merge pull request #160 from glebov-andrey/windows_dst_fix
Fixed issues with time zone UTC offset and daylight saving offset on Windows
This commit is contained in:
commit
7a813078aa
@ -170,7 +170,6 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
(void)tm; // avoid unused param warning
|
|
||||||
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
||||||
TIME_ZONE_INFORMATION tzinfo;
|
TIME_ZONE_INFORMATION tzinfo;
|
||||||
auto rv = GetTimeZoneInformation(&tzinfo);
|
auto rv = GetTimeZoneInformation(&tzinfo);
|
||||||
@ -178,9 +177,14 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
|||||||
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
||||||
auto rv = GetDynamicTimeZoneInformation(&tzinfo);
|
auto rv = GetDynamicTimeZoneInformation(&tzinfo);
|
||||||
#endif
|
#endif
|
||||||
if (!rv)
|
if (rv == TIME_ZONE_ID_INVALID)
|
||||||
return -1;
|
return -1;
|
||||||
return -1 * (tzinfo.Bias + tzinfo.DaylightBias);
|
int offset = -tzinfo.Bias;
|
||||||
|
if (tm.tm_isdst)
|
||||||
|
offset -= tzinfo.DaylightBias;
|
||||||
|
else
|
||||||
|
offset -= tzinfo.StandardBias;
|
||||||
|
return offset;
|
||||||
#else
|
#else
|
||||||
return static_cast<int>(tm.tm_gmtoff / 60);
|
return static_cast<int>(tm.tm_gmtoff / 60);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user