home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / datetime / navytime / settz.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-27  |  1.1 KB  |  32 lines

  1. /* settz -- set time zone information from environment (Turbo C)            */
  2. /* copyright 1987  Michael M Rubenstein                                     */
  3.  
  4. /* Examines the environment variable TZ and sets timezone and daylight      */
  5. /* accordingly.  TZ should consist of 0 or more letters, an integer , 0 or  */
  6. /* more letters.  The initial letters are ignored.  The integer (which may  */
  7. /* be negative) gives the number of hours behind GMT.  If any letters       */
  8. /* follow the integer, daylight is set to 1.                                */
  9.  
  10. /* For EST/DST, the environment variable TZ should be EST5DST.  For EST     */
  11. /* only, the variable should be EST5.  At present the letters are ignored   */
  12. /* except for setting daylight.                                             */
  13.  
  14. #include <stdio.h>
  15. #include <time.h>
  16. #include <stdlib.h>
  17. #include <ctype.h>
  18.  
  19. void settz(void)
  20. {
  21.   char                  *tz;
  22.  
  23.   if ((tz = getenv("TZ")) == NULL)
  24.     return;
  25.   while (isalpha(*tz))
  26.     ++tz;
  27.   timezone = (long) atoi(tz) * 3600l;
  28.   while (*tz != '\0' && !isalpha(*tz))
  29.     ++tz;
  30.   daylight = (*tz != '\0');
  31. }
  32.