From: Brian J. <bjj...@us...> - 2001-07-05 19:13:40
|
I finally tracked down why the MacOS time always reas as GMT when running BII on Irix: the __SVR4 case in TimerDateTime() wasn't getting selected, since Irix defines _SVR4_SOURCE instead of __SVR4. But even with fixed #ifdefs, it didn't pick up on daylight savings time. Apparently Irix uses separate globals for the offset from GMT for daylight savings time and standard time. The following seems to do the right thing on Irix: > cvs diff -u timer_unix.cpp Index: timer_unix.cpp =================================================================== RCS file: /cvs/BasiliskII/src/Unix/timer_unix.cpp,v retrieving revision 1.9 diff -u -r1.9 timer_unix.cpp --- timer_unix.cpp 2001/02/02 20:52:58 1.9 +++ timer_unix.cpp 2001/07/05 19:01:26 @@ -60,6 +60,9 @@ time_t utc_now = time(NULL); #if defined(__linux__) || defined(__SVR4) time_t local_now = utc_now - timezone; +#elif defined(sgi) + time_t local_now = utc_now - (localtime(&utc_now)->tm_isdst ? + altzone : timezone); #elif defined(__FreeBSD__) || defined(__NetBSD__) time_t local_now = utc_now + localtime(&utc_now)->tm_gmtoff; #else I have no idea if "altzone" is supported on any other systems; the Linux man pages don't mention it. But wouldn't the easier way to do this be to call localtime(), and reconstruct the local time in seconds from the tm_sec, tm_min, tm_hour, tm_yday, and tm_year fields? That way localtime() would do all the timezone and daylight savings time adjustments, in a fully portable way. Brian -------------------------------------------------------------------- "Think big thoughts but relish small pleasures." -- Life's Little Instruction Book |