home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_07 / MARK_WC2.LZH / INCLUDE / TIME.H < prev    next >
C/C++ Source or Header  |  1988-04-27  |  5KB  |  142 lines

  1. /*
  2.  * time.h -- time and date services.
  3.  *
  4.  * Copyright (c) 1981-1988, Mark Williams Company, Chicago
  5.  * This file and its contents may not be copied or distributed
  6.  * without permission.
  7.  */
  8.  
  9. #ifndef TIME_H
  10. #define TIME_H
  11.  
  12. /*
  13.  * Clock function for process timing.
  14.  * This returns raw ticks, CLK_TCK per second,
  15.  * for the process's personal interpretation.
  16.  */
  17. #if GEMDOS
  18. #define CLK_TCK    200        /* 200 hz timer */
  19. typedef unsigned long clock_t;    /* 200 hz timer ticks */
  20. #endif
  21. clock_t clock();        /* (void) */
  22.  
  23. /*
  24.  * Time difference as a double.
  25.  */
  26. double difftime();        /* (time_t time1, time_t time2) */
  27.  
  28. /*
  29.  * Time function for calendar time.
  30.  * Draft ANSI standard leaves time_t implementation-dependent:
  31.  * ours is time_t is 32 bits of seconds,
  32.  * beginning January 1, 1970, 0h00m00s GMT.
  33.  */
  34. typedef unsigned long time_t;
  35. time_t time();            /* (time_t *timer) */
  36.  
  37. /*
  38.  * Time fields structure: struct "tm",
  39.  * aliased to "tm_t" for neatness.
  40.  * This structure is filled in by localtime() and gmtime().
  41.  * Note that "tm_mon" is 0 through 11,
  42.  * and "tm_year" is number of years since 1900.
  43.  */
  44. typedef struct    tm {
  45.     int    tm_sec;        /* Seconds (0-59) */
  46.     int    tm_min;        /* Minutes (0-59) */
  47.     int    tm_hour;    /* Hours (0-23); 0 = midnight */
  48.     int    tm_mday;    /* Day of month (1..28,29,30,31) */
  49.     int    tm_mon;        /* Month (0-11); 0 = January */
  50.     int    tm_year;    /* Year AD since 1900 */
  51.     int    tm_wday;    /* Day of week (0-6): 0 = Sunday */
  52.     int    tm_yday;    /* Day of year (0-365,366) */
  53.     int    tm_isdst;    /* Daylight savings time flag: */
  54.                 /* Non-standard, they make negative==NA */
  55. } tm_t;
  56.  
  57. /*
  58.  * Calendar time conversion functions:
  59.  */
  60. char    *asctime();    /* tm_t fields to ascii string */
  61. char    *ctime();    /* time_t * to ascii string */
  62. tm_t    *gmtime();    /* time_t * to standard time fields */
  63. tm_t    *localtime();    /* time_t * to local time fields */
  64.  
  65. /*
  66.  * Mark Williams extensions to the draft ANSI standard:
  67.  */
  68. /*
  69.  * Timezone and daylight savings time implementation.
  70.  * localtime() parses the TIMEZONE environmental parameter
  71.  * or default values to set timezone, tzname[][], and daylight
  72.  * savings time parameters.
  73.  */
  74. extern    long    timezone;    /* Seconds subtracted from standard time */
  75. extern    int    dstadjust;    /* Seconds added to local standard */
  76. extern    char    tzname[2][32];    /* Names of local standard and daylight zone */
  77.  
  78. /*
  79.  * Calendar utilities:
  80.  * Gregorian calendar counted from October 1582; Julian calendar
  81.  * before that.
  82.  * The month of Gregorian adjustment isn't right.
  83.  */
  84. int    isleapyear();        /* (year) AD */
  85. int    dayspermonth();        /* (month, year) [1..12], AD */
  86.  
  87. /*
  88.  * Julian day structure consists of the days and seconds since
  89.  * Greenwich mean noon of January 1st 4713 BC.
  90.  * COHERENT time_t is a variation of Julian time:
  91.  * it counts seconds from Julian day 2,440,587.5 (January 1, 1970).
  92.  */
  93. typedef struct { long j_d, j_s; } jday_t;
  94. #define COHEPOCH 2440587L        /* Julian day 1969.12.31 12h00m00s */
  95.  
  96. jday_t time_to_jday();            /* COHERENT time into Julian date */
  97. time_t jday_to_time();            /* Julian date to coherent time */
  98. jday_t tm_to_jday();            /* tm_t structure into Julian date */
  99. tm_t *jday_to_tm();            /* Julian date into tm_t structure */
  100.  
  101. #if GEMDOS
  102. /*
  103.  * Atari ST support.
  104.  * TOS time & date: packed binary date and time
  105.  * A "tetd_t" object is the object of xbios functions Gettime() and Settime().
  106.  * The halves are the objects of gemdos Tgettime(), Tgetdate(), Tsettime(),
  107.  * Tsetdate().
  108.  * The file time and date stamps that Fdatime(), Fsfirst(),
  109.  * and Fsnext() maintain are rtetd_t format:
  110.  * they reverse the order of the time
  111.  * and date fields from the utetd_t format used by Gettime() and Settime().
  112.  */
  113. typedef unsigned long tetd_t;
  114. typedef struct { unsigned g_date, g_time; } utetd_t;
  115. typedef struct { unsigned g_rtime, g_rdate; } rtetd_t;
  116.  
  117. tetd_t tm_to_tetd();        /* tm_t structure into TOS time and date */
  118. tm_t *tetd_to_tm();        /* TOS time and date into tm_t */
  119. #define tetd_to_jday(td)    tm_to_jday(tetd_to_tm(td))
  120. #define jday_to_tetd(jd)    tm_to_tetd(jday_to_tm(jd))
  121. #define tetd_to_time(td)    jday_to_time(tetd_to_jday(td))
  122. #define time_to_tetd(t)        jday_to_tetd(time_to_jday(t))
  123.  
  124. /*
  125.  * The intelligent keyboard keeps time to the second
  126.  * which neither xbios or gemdos support.
  127.  * These two functions operate on tm_t objects.
  128.  */
  129. tm_t *Kgettime();    /* (void) */
  130. int Ksettime();        /* (tm_t *timep) */
  131.  
  132. /*
  133.  * Similar routines for the XBIOS time.
  134.  * These two functions operate on tm_t objects.
  135.  */
  136. tm_t *Sgettime();    /* (void) */
  137. int Ssettime();        /* (tm_t *timep) */
  138. #endif
  139. #endif
  140.  
  141. /* end of time.h */
  142.