home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnuawk.zip / missing / tzset.c < prev   
C/C++ Source or Header  |  1993-11-25  |  681b  |  40 lines

  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, rick@uunet.uu.net, 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. }
  40.