X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ftime%2Ftimezone.cpp;h=76c3fb242463fe3f5f504c37e3f0a95a616d223c;hp=541514f8b8272c1573b4a361c85675a3cf92ce09;hb=be8ea216d23bf36bdfb2d3e302638782575fc136;hpb=cb8ed1df371834fb7766e0b7754cdf83c474d394 diff --git a/source/time/timezone.cpp b/source/time/timezone.cpp index 541514f..76c3fb2 100644 --- a/source/time/timezone.cpp +++ b/source/time/timezone.cpp @@ -1,51 +1,9 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include -#include -#include -#ifdef WIN32 -#include -#else -#include -#endif -#include +#include #include "timezone.h" -#include "units.h" using namespace std; -namespace { - -using Msp::Time::TimeZone; - -TimeZone get_local_timezone() -{ -#ifdef WIN32 - TIME_ZONE_INFORMATION tzinfo; - DWORD dst=GetTimeZoneInformation(&tzinfo); - if(dst==TIME_ZONE_ID_INVALID) - throw Msp::SystemError("Failed to get time zone information", GetLastError()); - - 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); -#else - tzset(); - return TimeZone(timezone/60); -#endif -} - -} - namespace Msp { namespace Time { @@ -53,22 +11,25 @@ TimeZone::TimeZone(): name("UTC") { } -TimeZone::TimeZone(int minutes_west): - offset(minutes_west*min) +TimeZone::TimeZone(int minutes): + offset(minutes*min) { - if(minutes_west) + if(minutes) { - ostringstream ss; - ss.fill('0'); - int m=abs(minutes_west); - ss<<"UTC"<<(minutes_west<0 ? '-' : '+')<