X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ftime%2Ftimezone.cpp;h=56fcf8f588a389325a1fda85cec2577b82b1c54d;hp=9c146249208da8206ae6c1c937526afcde56fe21;hb=967785734be5c3fc6f75da122c2d93ebbb338271;hpb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd diff --git a/source/time/timezone.cpp b/source/time/timezone.cpp index 9c14624..56fcf8f 100644 --- a/source/time/timezone.cpp +++ b/source/time/timezone.cpp @@ -1,19 +1,11 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2008-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include -#include -#include #ifdef WIN32 #include #else #include #endif -#include "../core/except.h" +#include +#include #include "timestamp.h" #include "timezone.h" #include "units.h" @@ -41,7 +33,7 @@ TimeZone get_local_timezone() TIME_ZONE_INFORMATION tzinfo; DWORD dst = GetTimeZoneInformation(&tzinfo); if(dst==TIME_ZONE_ID_INVALID) - throw Msp::SystemError("Failed to get time zone information", GetLastError()); + throw Msp::system_error("GetTimeZoneInformation"); int offset = tzinfo.Bias; if(dst==TIME_ZONE_ID_STANDARD) @@ -52,7 +44,7 @@ TimeZone get_local_timezone() return TimeZone(offset); #else int fd = open("/etc/localtime", O_RDONLY); - if(fd>=-1) + if(fd!=-1) { char hdr[44]; int len = read(fd, hdr, sizeof(hdr)); @@ -102,7 +94,7 @@ TimeZone get_local_timezone() close(fd); if(gmtoff!=-1) - return TimeZone(-gmtoff/60, name); + return TimeZone(gmtoff/60, name); } return TimeZone(); #endif @@ -117,25 +109,23 @@ 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 ? '-' : '+')<