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
This commit is contained in:
Bruce Allen 2005-05-05 04:26:52 +00:00
parent 1ae7d9b042
commit 34c44c01e9
2 changed files with 28 additions and 2 deletions

View File

@ -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

View File

@ -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