| 1 |
/* |
| 2 |
* tzset.c |
| 3 |
* |
| 4 |
* Quick and dirty emulation of tzset(), tzname[], and daylight |
| 5 |
* for old BSD systems without it. |
| 6 |
* |
| 7 |
* Thanks to Rick Adams, [email protected], for the basics. |
| 8 |
* |
| 9 |
* BUGS: |
| 10 |
* Totally ignores the value of the TZ environment variable. |
| 11 |
*/ |
| 12 |
|
| 13 |
#if 0 |
| 14 |
#include <time.h> |
| 15 |
#endif |
| 16 |
#include <sys/time.h> |
| 17 |
|
| 18 |
static char tz1[1024]; |
| 19 |
static char tz2[1024]; |
| 20 |
|
| 21 |
/* external variables */ |
| 22 |
char *tzname[2] = { |
| 23 |
tz1, tz2 |
| 24 |
}; |
| 25 |
int daylight; |
| 26 |
|
| 27 |
extern char *timezone(); |
| 28 |
|
| 29 |
void |
| 30 |
tzset() |
| 31 |
{ |
| 32 |
struct timeval tp; |
| 33 |
struct timezone tz; |
| 34 |
|
| 35 |
(void) gettimeofday(&tp, &tz); |
| 36 |
(void) strcpy(tz1, timezone(tz.tz_minuteswest, 0)); |
| 37 |
(void) strcpy(tz2, timezone(tz.tz_minuteswest, 1)); |
| 38 |
daylight = tz.tz_dsttime; |
| 39 |
} |