From 34c44c01e93645c52101eff2e63559a0b2365ba1 Mon Sep 17 00:00:00 2001 From: Bruce Allen Date: Thu, 5 May 2005 04:26:52 +0000 Subject: [PATCH] Bug fix so that Unix hosts report their timezones correctly. NOTE: hosts that lack a gmt offset in the tm structure (System V with no BSD extensions) will have the WRONG SIGN for the timezone. This can be fixed by changing the signs of __timezone, _timezone and timezone in get_timezone(), but I won't do it until David signs off. Note that with this change we adopt the convention that the database timezone value is the (Local Standard Time) - (UTC time). This quantity only depends upon spatial location on the earth's surface and is NOT a function of time. svn path=/trunk/boinc/; revision=6027 --- checkin_notes | 16 ++++++++++++++++ client/hostinfo_unix.C | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/checkin_notes b/checkin_notes index e5c95521c8..5943637372 100755 --- a/checkin_notes +++ b/checkin_notes @@ -6055,3 +6055,19 @@ David 4 May 2005 boinc_api.C db/ schema.sql + +Bruce 4 May 2005 + - bug fix so that Unix hosts report their timezones correctly. + NOTE: hosts that lack a gmt offset in the tm structure (System V + with no BSD extensions) will have the WRONG SIGN for the timezone. + This can be fixed by changing the signs of __timezone, _timezone and + timezone in get_timezone(), but I won't do it until David signs + off. + - Note that with this change we adopt the convention that the database + timezone value is the (Local Standard Time) - (UTC time). This + quantity only depends upon spatial location on the earth's surface and + is NOT a function of time. + + client/ + hostinfo_unix.C + diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index b2af285915..0655eb2eff 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -98,7 +98,8 @@ char* ip_addr_string(int ip_addr) { } #endif -// Returns the number of seconds difference from UTC +// Returns the offset between LOCAL STANDARD TIME and UTC. +// LOCAL_STANDARD_TIME = UTC_TIME + get_timezone(). // int get_timezone() { tzset(); @@ -109,13 +110,22 @@ int get_timezone() { cur_time = time(NULL); time_data = localtime( &cur_time ); - return time_data->tm_gmtoff; + if (time_data->tm_isdst>0) { + // daylight savings in effect + return (time_data->tm_gmtoff)-3600; + } else { + // no daylight savings in effect + return time_data->tm_gmtoff; + } #elif defined(linux) return __timezone; + // SHOULD BE -1*__timezone; #elif defined(__CYGWIN32__) return _timezone; + // SHOULD BE -1*_timezone; #elif defined(unix) return timezone; + // SHOULD BE -1*timezone; #else #error timezone #endif