]> git.tdb.fi Git - libs/core.git/blob - source/time/windows/timezone.cpp
Move non-oneliner functions out of RefPtr class declaration
[libs/core.git] / source / time / windows / timezone.cpp
1 #include <windows.h>
2 #include <msp/core/systemerror.h>
3 #include "timezone.h"
4
5 namespace Msp {
6 namespace Time {
7
8 TimeZone TimeZone::platform_get_local_timezone()
9 {
10         TIME_ZONE_INFORMATION tzinfo;
11         DWORD dst = GetTimeZoneInformation(&tzinfo);
12         if(dst==TIME_ZONE_ID_INVALID)
13                 throw Msp::system_error("GetTimeZoneInformation");
14
15         int offset = tzinfo.Bias;
16         if(dst==TIME_ZONE_ID_STANDARD)
17                 offset += tzinfo.StandardBias;
18         else if(dst==TIME_ZONE_ID_DAYLIGHT)
19                 offset += tzinfo.DaylightBias;
20
21         return TimeZone(offset);
22 }
23
24 } // namespace Time
25 } // namespace Msp