1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-16 00:04:59 +00:00

Fix detection of timezone offset for FreeBSD. (Refs Interlisp/medley/#65)

modified:   src/timer.c
This commit is contained in:
Nick Briggs 2020-11-23 20:42:15 -08:00
parent d9d917ab82
commit d8c0ab9bdf

View File

@ -317,9 +317,16 @@ static int gettime(int casep)
case 8:
/* other methods of determining timezone offset are unreliable and/or deprecated */
/* timezone is declared in <time.h>; the time mechanisms must be initialized */
/* Unfortunately, FreeBSD does not support the timezone external variable, nor */
/* does gettimeofday() seem to produce the correct timezone values. */
tzset();
#if defined(FREEBSD)
time_t tv = time(NULL);
struct tm *tm = localtime(&tv);
return (tm->tm_gmtoff / -3600);
#else
return (timezone / 3600); /* timezone, extern, is #secs diff GMT to local. */
#endif
default: return (0);
}
}