home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 04stdlib / timedata.c < prev   
Encoding:
C/C++ Source or Header  |  1988-08-11  |  794 b   |  35 lines

  1. /*
  2.  *    timedata -- time zone and time value tests
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <time.h>
  7.  
  8. main()
  9. {
  10.     long now;
  11.     struct tm *tbuf;
  12.     
  13.     /* get TZ data into global variables */
  14.     tzset();
  15.  
  16.     /* display the global time values */
  17.     printf("daylight savings time flag = %d\n", daylight);
  18.     printf("difference (in seconds) from GMT = %ld\n", timezone);
  19.     printf("standard time zone string is %s\n", tzname[0]);
  20.     printf("daylight time zone string is %s\n", tzname[1]);
  21.  
  22.     /*
  23.      *  display the current date and time values for
  24.      *  local and universal time
  25.      */
  26.     now = time(NULL);
  27.     printf("\nctime():\t%s\n", ctime(&now));
  28.     tbuf = localtime(&now);
  29.     printf("local time:\t%s\n", asctime(tbuf));
  30.     tbuf = gmtime(&now);
  31.     printf("universal time:\t%s\n", asctime(tbuf));
  32.  
  33.     exit(0);
  34. }
  35.