From cd8ce7e17a54b954d3887a9a1041d8d1bb608304 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Thu, 18 Jul 2002 21:14:32 +0000 Subject: [PATCH] Fixed get_timezone function to work on all platforms correctly. svn path=/trunk/boinc/; revision=220 --- client/hostinfo_unix.C | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index fdf55f2897..407bb89469 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -118,17 +118,15 @@ char* ip_addr_string(int ip_addr) { return inet_ntoa(ia); } -// What does this return? # of seconds from GMT? +// Returns the number of seconds difference from UTC // -void get_timezone(int& tz) { - tzset(); +int get_timezone( void ) { + time_t cur_time; + struct tm *time_data; - // TODO: take daylight savings time into account -#ifdef __timezone - tz = __timezone; -#else - tz = timezone; -#endif + cur_time = time(NULL); + time_data = localtime( &cur_time ); + return time_data->tm_gmtoff; } // Returns true if the host is currently running off battery power @@ -255,7 +253,7 @@ int get_host_info(HOST_INFO& host) { #endif get_local_domain_name(host.domain_name); get_local_ip_addr_str(host.ip_addr); - get_timezone(host.timezone); + host.timezone = get_timezone(); #ifdef HAVE_SYS_UTSNAME_H get_osinfo(host); #endif