1987-01-27 15:57:55 +00:00
|
|
|
#ifdef BSD4_2
|
|
|
|
#include <sys/time.h>
|
|
|
|
#else
|
|
|
|
#ifndef USG
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/timeb.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1987-02-05 21:04:40 +00:00
|
|
|
#ifdef USG
|
1987-01-27 15:57:55 +00:00
|
|
|
long timezone = -1 * 60;
|
|
|
|
int daylight = 1;
|
|
|
|
char *tzname[] = {"MET", "MDT",};
|
1987-02-05 21:04:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
long __timezone = -1 * 60;
|
|
|
|
int __daylight = 1;
|
|
|
|
char *__tzname[] = {"MET", "MDT", };
|
1987-01-27 15:57:55 +00:00
|
|
|
|
|
|
|
tzset()
|
|
|
|
{
|
|
|
|
#ifdef BSD4_2
|
|
|
|
struct timeval tval;
|
|
|
|
struct timezone tzon;
|
|
|
|
|
|
|
|
gettimeofday(&tval, &tzon);
|
1987-02-05 21:04:40 +00:00
|
|
|
__timezone = tzon.tz_minuteswest * 60L;
|
|
|
|
__daylight = tzon.tz_dsttime;
|
1987-01-27 15:57:55 +00:00
|
|
|
#else
|
|
|
|
#ifndef USG
|
|
|
|
struct timeb time;
|
|
|
|
|
|
|
|
ftime(&time);
|
1987-02-05 21:04:40 +00:00
|
|
|
__timezone = time.timezone*60L;
|
|
|
|
__daylight = time.dstflag;
|
1987-01-27 15:57:55 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
extern char *getenv();
|
|
|
|
register char *p = getenv("TZ");
|
|
|
|
|
|
|
|
if (p && *p) {
|
|
|
|
register int n = 0;
|
|
|
|
int sign = 1;
|
|
|
|
|
1987-02-05 21:07:09 +00:00
|
|
|
strncpy(__tzname[0], p, 3);
|
1987-01-27 15:57:55 +00:00
|
|
|
p += 3;
|
|
|
|
if (*(p += 3) == '-') {
|
|
|
|
sign = -1;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(*p >= '0' && *p <= '9')
|
|
|
|
n = 10 * n + (*p++ - '0');
|
|
|
|
n *= sign;
|
1987-02-05 21:04:40 +00:00
|
|
|
__timezone = ((long)(n * 60)) * 60;
|
|
|
|
__daylight = (*p != '\0');
|
1987-02-05 21:07:09 +00:00
|
|
|
strncpy(__tzname[1], p, 3);
|
1987-01-27 15:57:55 +00:00
|
|
|
}
|
|
|
|
}
|
1987-02-05 21:04:40 +00:00
|
|
|
#ifdef USG
|
|
|
|
timezone = __timezone;
|
|
|
|
daylight = __daylight;
|
|
|
|
tzname[0] = __tzname[0];
|
|
|
|
tzname[1] = __tzname[1];
|
|
|
|
#endif
|
1987-01-27 15:57:55 +00:00
|
|
|
}
|