home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / cecko / install / devcpp4920.exe / include / time.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-17  |  5.4 KB  |  220 lines

  1. /* 
  2.  * time.h
  3.  *
  4.  * Date and time functions and types.
  5.  *
  6.  * This file is part of the Mingw32 package.
  7.  *
  8.  * Contributors:
  9.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  10.  *
  11.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  12.  *
  13.  *  This source code is offered for use in the public domain. You may
  14.  *  use, modify or distribute it freely.
  15.  *
  16.  *  This code is distributed in the hope that it will be useful but
  17.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18.  *  DISCLAMED. This includes but is not limited to warranties of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Revision: 1.6 $
  22.  * $Author: cgf $
  23.  * $Date: 2000/02/05 04:04:58 $
  24.  *
  25.  */
  26.  
  27. #ifndef    _TIME_H_
  28. #define    _TIME_H_
  29.  
  30. /* All the headers include this file. */
  31. #include <_mingw.h>
  32.  
  33. #define __need_wchar_t
  34. #define __need_size_t
  35. #ifndef RC_INVOKED
  36. #include <stddef.h>
  37. #endif    /* Not RC_INVOKED */
  38.  
  39. /*
  40.  * Need a definition of time_t.
  41.  */
  42. #include <sys/types.h>
  43.  
  44. /*
  45.  * Number of clock ticks per second. A clock tick is the unit by which
  46.  * processor time is measured and is returned by 'clock'.
  47.  */
  48. #define    CLOCKS_PER_SEC    ((clock_t)1000)
  49. #define    CLK_TCK        CLOCKS_PER_SEC
  50.  
  51.  
  52. #ifndef RC_INVOKED
  53.  
  54. /*
  55.  * A type for storing the current time and date. This is the number of
  56.  * seconds since midnight Jan 1, 1970.
  57.  * NOTE: Normally this is defined by the above include of sys/types.h
  58.  */
  59. #ifndef _TIME_T_DEFINED
  60. typedef    long    time_t;
  61. #define _TIME_T_DEFINED
  62. #endif
  63.  
  64. /*
  65.  * A type for measuring processor time (in clock ticks).
  66.  */
  67. #ifndef _CLOCK_T_DEFINED
  68. typedef    long    clock_t;
  69. #define _CLOCK_T_DEFINED
  70. #endif
  71.  
  72.  
  73. /*
  74.  * A structure for storing all kinds of useful information about the
  75.  * current (or another) time.
  76.  */
  77. struct tm
  78. {
  79.     int    tm_sec;        /* Seconds: 0-59 (K&R says 0-61?) */
  80.     int    tm_min;        /* Minutes: 0-59 */
  81.     int    tm_hour;    /* Hours since midnight: 0-23 */
  82.     int    tm_mday;    /* Day of the month: 1-31 */
  83.     int    tm_mon;        /* Months *since* january: 0-11 */
  84.     int    tm_year;    /* Years since 1900 */
  85.     int    tm_wday;    /* Days since Sunday (0-6) */
  86.     int    tm_yday;    /* Days since Jan. 1: 0-365 */
  87.     int    tm_isdst;    /* +1 Daylight Savings Time, 0 No DST,
  88.                  * -1 don't know */
  89. };
  90.  
  91. #ifdef    __cplusplus
  92. extern "C" {
  93. #endif
  94.  
  95. clock_t    clock (void);
  96. time_t    time (time_t*);
  97. double    difftime (time_t, time_t);
  98. time_t    mktime (struct tm*);
  99.  
  100. /*
  101.  * These functions write to and return pointers to static buffers that may
  102.  * be overwritten by other function calls. Yikes!
  103.  *
  104.  * NOTE: localtime, and perhaps the others of the four functions grouped
  105.  * below may return NULL if their argument is not 'acceptable'. Also note
  106.  * that calling asctime with a NULL pointer will produce an Invalid Page
  107.  * Fault and crap out your program. Guess how I know. Hint: stat called on
  108.  * a directory gives 'invalid' times in st_atime etc...
  109.  */
  110. char*        asctime (const struct tm*);
  111. char*        ctime (const time_t*);
  112. struct tm*    gmtime (const time_t*);
  113. struct tm*    localtime (const time_t*);
  114.  
  115.  
  116. size_t    strftime (char*, size_t, const char*, const struct tm*);
  117.  
  118. size_t    wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
  119.  
  120. #ifndef __STRICT_ANSI__
  121. extern void    _tzset (void);
  122.  
  123. #ifndef _NO_OLDNAMES
  124. extern void    tzset (void);
  125. #endif
  126.  
  127. size_t    strftime(char*, size_t, const char*, const struct tm*);
  128. char*    _strdate(char*);
  129. char*    _strtime(char*);
  130.  
  131. #endif    /* Not __STRICT_ANSI__ */
  132.  
  133. /*
  134.  * _daylight: non zero if daylight savings time is used.
  135.  * _timezone: difference in seconds between GMT and local time.
  136.  * _tzname: standard/daylight savings time zone names (an array with two
  137.  *          elements).
  138.  */
  139. #ifdef __MSVCRT__
  140.  
  141. /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
  142. extern int*    __p__daylight (void);
  143. extern long*    __p__timezone (void);
  144. extern char**    __p__tzname (void);
  145.  
  146. __MINGW_IMPORT int    _daylight;
  147. __MINGW_IMPORT long    _timezone;
  148. __MINGW_IMPORT char     *_tzname[2];
  149.  
  150. #else /* not __MSVCRT (ie. crtdll) */
  151.  
  152. #ifndef __DECLSPEC_SUPPORTED
  153.  
  154. extern int*    __imp__daylight_dll;
  155. extern long*    __imp__timezone_dll;
  156. extern char**    __imp__tzname;
  157.  
  158. #define _daylight    (*__imp__daylight_dll)
  159. #define _timezone    (*__imp__timezone_dll)
  160. #define _tzname        (__imp__tzname)
  161.  
  162. #else /* __DECLSPEC_SUPPORTED */
  163.  
  164. __MINGW_IMPORT int    _daylight_dll;
  165. __MINGW_IMPORT long    _timezone_dll;
  166. __MINGW_IMPORT char*    _tzname[2];
  167.  
  168. #define _daylight    _daylight_dll
  169. #define _timezone    _timezone_dll
  170.  
  171. #endif /* __DECLSPEC_SUPPORTED */
  172.  
  173. #endif /* not __MSVCRT__ */
  174.  
  175. #ifndef _NO_OLDNAMES
  176.  
  177. #ifdef __MSVCRT__
  178.  
  179. /* These go in the oldnames import library for MSVCRT. */
  180. __MINGW_IMPORT int    daylight;
  181. __MINGW_IMPORT long    timezone;
  182. __MINGW_IMPORT char     *tzname[2];
  183.  
  184. #ifndef _WTIME_DEFINED
  185.  
  186. /* wide function prototypes, also declared in wchar.h */
  187.  
  188. wchar_t *    _wasctime(const struct tm*);
  189. wchar_t *    _wctime(const time_t*);
  190. wchar_t*    _wstrdate(wchar_t*);
  191. wchar_t*    _wstrtime(wchar_t*);
  192.  
  193. #define _WTIME_DEFINED
  194. #endif /* _WTIME_DEFINED */ 
  195.  
  196.  
  197. #else /* not __MSVCRT__ */
  198.  
  199. /* CRTDLL is royally messed up when it comes to these macros.
  200.    TODO: import and alias these via oldnames import library instead 
  201.    of macros.  */
  202.  
  203. #define daylight        _daylight
  204. /* NOTE: timezone not defined because it would conflict with sys/timeb.h.
  205.    Also, tzname used to a be macro, but now it's in moldname. */
  206. __MINGW_IMPORT char     *tzname[2];
  207.  
  208. #endif /* not __MSVCRT__ */
  209.  
  210. #endif    /* Not _NO_OLDNAMES */
  211.  
  212. #ifdef    __cplusplus
  213. }
  214. #endif
  215.  
  216. #endif    /* Not RC_INVOKED */
  217.  
  218. #endif    /* Not _TIME_H_ */
  219.  
  220.