X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ftime%2Fwindows%2Ftimezone.cpp;fp=source%2Ftime%2Fwindows%2Ftimezone.cpp;h=570c6791d52e155759c12a2239946c5949b118a3;hp=0000000000000000000000000000000000000000;hb=609c9a508cfdc7b42c46c4f21d17639204165a00;hpb=b4806214e905752617691f851717033fd3f266c2 diff --git a/source/time/windows/timezone.cpp b/source/time/windows/timezone.cpp new file mode 100644 index 0000000..570c679 --- /dev/null +++ b/source/time/windows/timezone.cpp @@ -0,0 +1,25 @@ +#include +#include +#include "timezone.h" + +namespace Msp { +namespace Time { + +TimeZone TimeZone::platform_get_local_timezone() +{ + TIME_ZONE_INFORMATION tzinfo; + DWORD dst = GetTimeZoneInformation(&tzinfo); + if(dst==TIME_ZONE_ID_INVALID) + throw Msp::system_error("GetTimeZoneInformation"); + + int offset = tzinfo.Bias; + if(dst==TIME_ZONE_ID_STANDARD) + offset += tzinfo.StandardBias; + else if(dst==TIME_ZONE_ID_DAYLIGHT) + offset += tzinfo.DaylightBias; + + return TimeZone(offset); +} + +} // namespace Time +} // namespace Msp