Ideally, what I\'d like to be able to do is take the name of a time zone and ask Windows for its corresponding time zone info (offset from UTC, DST offset, dates for DST swi
Here is an example without the registry. The timezone information depends on the year, so I added a parameter to hold that.
TIME_ZONE_INFORMATION GmtTimezone( const wstring& name, SYSTEMTIME utc )
{
DYNAMIC_TIME_ZONE_INFORMATION dynamicTimezone = {};
DWORD result=0;
for( DWORD i = 0; result!=ERROR_NO_MORE_ITEMS; ++i )
{
result = ::EnumDynamicTimeZoneInformation( i, &dynamicTimezone );
if( result==ERROR_SUCCESS && name==dynamicTimezone.StandardName )
break;
}
if( result!=ERROR_SUCCESS )
throw L"Could not find timezone "+name;
TIME_ZONE_INFORMATION tz;
if( !GetTimeZoneInformationForYear(static_cast(utc.wYear), &dynamicTimezone, &tz) )
throw "GetTimeZoneInformationForYear failed"+std::to_string(GetLastError());
return tz;
//SYSTEMTIME localTime;
//SystemTimeToTzSpecificLocalTime( &tz, &utc, &localTime );
//auto offsetHours = localTime.wHour-utc.wHour;
}