$NetBSD: patch-ak,v 1.1 2006/10/12 14:14:13 joerg Exp $ --- src/pl-tai.c.orig 2006-07-28 09:20:12.000000000 +0000 +++ src/pl-tai.c @@ -38,11 +38,8 @@ long set by tzset(). Not really clean . #ifdef WIN32 #define timezone _timezone -#define daylight _daylight #else extern char *tzname[2]; -extern long timezone; -extern int daylight; #endif @@ -82,8 +79,21 @@ do_tzset() static int tz_offset() -{ do_tzset(); - return timezone; +{ + time_t now = time(NULL), t_gmt, t_local; + struct tm gmt, local; + int diff; + + do_tzset(); + gmtime_r(&now, &gmt); + t_gmt = mktime(&gmt); + localtime_r(&now, &local); + t_local = mktime(&local); + diff = t_local - t_gmt; + if (local.tm_isdst) + diff += 3600; + + return diff; } @@ -312,14 +322,12 @@ PRED_IMPL("stamp_date_time", 3, stamp_da ct.hour = tm.tm_hour; ct.minute = tm.tm_min; tzatom = tz_name_as_atom(tm.tm_isdst); - if ( daylight ) /* from tzset() */ - { if ( tm.tm_isdst ) + if ( tm.tm_isdst ) { utcoffset -= 3600; dstatom = ATOM_true; } else { dstatom = ATOM_false; } - } done = TRUE; } } else if ( alocal == ATOM_utc ) @@ -721,12 +729,10 @@ PRED_IMPL("format_time", 3, format_time, { localtime_r(&unixt, &tb.tm); tb.sec = (double)tb.tm.tm_sec + modf(tb.stamp, &ip); tb.utcoff = tz_offset(); - if ( daylight ) - { if ( tb.tm.tm_isdst ) + if ( tb.tm.tm_isdst ) { tb.utcoff -= 3600; tb.isdst = TRUE; } - } tb.tzname = tz_name_as_atom(tb.tm.tm_isdst); tb.flags = HAS_STAMP|HAS_WYDAY; } else