ack/lang/cem/libcc/gen/tzset.c

85 lines
1.3 KiB
C
Raw Permalink Normal View History

1994-06-24 14:02:31 +00:00
/* $Id$ */
#ifdef __BSD4_2
struct timeval {
long tv_sec, tv_usec;
};
struct timezone {
int tz_minuteswest, tz_dsttime;
};
1987-01-27 15:57:55 +00:00
#else
#ifndef __USG
1987-01-27 15:57:55 +00:00
#include <sys/types.h>
struct timeb
{
time_t time;
ushort millitm;
short timezone;
short dstflag;
};
1987-01-27 15:57:55 +00:00
#endif
#endif
#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
1987-01-27 15:57:55 +00:00
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
#if minix || minixST
__timezone = 0L;
__daylight = 0;
#else
1987-01-27 15:57:55 +00:00
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
1987-01-27 15:57:55 +00:00
#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
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
}
}
#ifdef __USG
1987-02-05 21:04:40 +00:00
timezone = __timezone;
daylight = __daylight;
tzname[0] = __tzname[0];
tzname[1] = __tzname[1];
#endif
1987-01-27 15:57:55 +00:00
}