From de13de9e4d784dd1c72e6cb0266e36bec1eced13 Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Thu, 6 Jun 2002 07:12:34 +0000 Subject: [PATCH] Final? fix to timezone detection --- goldlib/gall/gtimutil.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/goldlib/gall/gtimutil.cpp b/goldlib/gall/gtimutil.cpp index f816d76..4e5337c 100644 --- a/goldlib/gall/gtimutil.cpp +++ b/goldlib/gall/gtimutil.cpp @@ -67,16 +67,12 @@ const char* gmonths[] = { int tzoffset() { - time_t t = time(NULL); - struct tm *a = localtime(&t); - int tz = a->tm_hour * 100 + a->tm_min; - a = gmtime(&t); - tz -= a->tm_hour * 100 + a->tm_min; - if(tz < -24*100) - tz += 24*100; - else if(tz > 24*100) - tz -= 24*100; - return tz; + time_t t1 = time(NULL); + struct tm *tp = gmtime(&t1); + tp->tm_isdst=-1; + time_t t2 = mktime(tp); + int dt = (int)(t1 - t2); + return (dt / 3600) * 100 + (dt % 3600) / 60; }