3 This file is part of libmspcore
4 Copyright © 2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
19 using Msp::Time::TimeZone;
21 TimeZone get_local_timezone()
24 TIME_ZONE_INFORMATION tzinfo;
25 DWORD dst=GetTimeZoneInformation(&tzinfo);
26 if(dst==TIME_ZONE_ID_INVALID)
27 throw SystemError("Failed to get time zone information", GetLastError());
29 int offset=tzinfo.Bias;
30 if(dst==TIME_ZONE_ID_STANDARD)
31 offset+=tzinfo.StandardBias;
32 else if(dst==TIME_ZONE_ID_DAYLIGHT)
33 offset+=tzinfo.DaylightBias;
35 return TimeZone(offset);
38 return TimeZone(timezone/60);
51 TimeZone::TimeZone(int minutes_west):
52 offset(minutes_west*min)
58 int m=abs(minutes_west);
59 ss<<"UTC"<<(minutes_west<0 ? '-' : '+')<<m/60;
61 ss<<':'<<setw(2)<<m%60;
67 const TimeZone &TimeZone::utc()
69 static TimeZone tz(0);
73 const TimeZone &TimeZone::local()
75 static TimeZone tz=get_local_timezone();