time.h
Upload User: caisha3
Upload Date: 2013-09-21
Package Size: 208739k
Code Size: 7k
Category:

Windows Develop

Development Platform:

Visual C++

  1. /***
  2. *time.h - definitions/declarations for time routines
  3. *
  4. *       Copyright (c) 1985-1995, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       This file has declarations of time routines and defines
  8. *       the structure returned by the localtime and gmtime routines and
  9. *       used by asctime.
  10. *       [ANSI/System V]
  11. *
  12. *       [Public]
  13. *
  14. ****/
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif
  18. #ifndef _INC_TIME
  19. #define _INC_TIME
  20. #if !defined(_WIN32) && !defined(_MAC)
  21. #error ERROR: Only Mac or Win32 targets supported!
  22. #endif
  23. #ifdef  _MSC_VER
  24. /*
  25.  * Currently, all MS C compilers for Win32 platforms default to 8 byte
  26.  * alignment.
  27.  */
  28. #pragma pack(push,8)
  29. #endif  /* _MSC_VER */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  34. #ifndef _CRTAPI1
  35. #if     _MSC_VER >= 800 && _M_IX86 >= 300
  36. #define _CRTAPI1 __cdecl
  37. #else
  38. #define _CRTAPI1
  39. #endif
  40. #endif
  41. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  42. #ifndef _CRTAPI2
  43. #if     _MSC_VER >= 800 && _M_IX86 >= 300
  44. #define _CRTAPI2 __cdecl
  45. #else
  46. #define _CRTAPI2
  47. #endif
  48. #endif
  49. /* Define _CRTIMP */
  50. #ifndef _CRTIMP
  51. #ifdef  _NTSDK
  52. /* definition compatible with NT SDK */
  53. #define _CRTIMP
  54. #else   /* ndef _NTSDK */
  55. /* current definition */
  56. #ifdef  _DLL
  57. #define _CRTIMP __declspec(dllimport)
  58. #else   /* ndef _DLL */
  59. #define _CRTIMP
  60. #endif  /* _DLL */
  61. #endif  /* _NTSDK */
  62. #endif  /* _CRTIMP */
  63. /* Define __cdecl for non-Microsoft compilers */
  64. #if     ( !defined(_MSC_VER) && !defined(__cdecl) )
  65. #define __cdecl
  66. #endif
  67. #ifndef _MAC
  68. #ifndef _WCHAR_T_DEFINED
  69. typedef unsigned short wchar_t;
  70. #define _WCHAR_T_DEFINED
  71. #endif
  72. #endif /* ndef _MAC */
  73. /* Define the implementation defined time type */
  74. #ifndef _TIME_T_DEFINED
  75. typedef long time_t;        /* time value */
  76. #define _TIME_T_DEFINED     /* avoid multiple def's of time_t */
  77. #endif
  78. #ifndef _CLOCK_T_DEFINED
  79. typedef long clock_t;
  80. #define _CLOCK_T_DEFINED
  81. #endif
  82. #ifndef _SIZE_T_DEFINED
  83. typedef unsigned int size_t;
  84. #define _SIZE_T_DEFINED
  85. #endif
  86. /* Define NULL pointer value */
  87. #ifndef NULL
  88. #ifdef __cplusplus
  89. #define NULL    0
  90. #else
  91. #define NULL    ((void *)0)
  92. #endif
  93. #endif
  94. #ifndef _TM_DEFINED
  95. struct tm {
  96.         int tm_sec;     /* seconds after the minute - [0,59] */
  97.         int tm_min;     /* minutes after the hour - [0,59] */
  98.         int tm_hour;    /* hours since midnight - [0,23] */
  99.         int tm_mday;    /* day of the month - [1,31] */
  100.         int tm_mon;     /* months since January - [0,11] */
  101.         int tm_year;    /* years since 1900 */
  102.         int tm_wday;    /* days since Sunday - [0,6] */
  103.         int tm_yday;    /* days since January 1 - [0,365] */
  104.         int tm_isdst;   /* daylight savings time flag */
  105.         };
  106. #define _TM_DEFINED
  107. #endif
  108. /* Clock ticks macro - ANSI version */
  109. #define CLOCKS_PER_SEC  1000
  110. /* Extern declarations for the global variables used by the ctime family of
  111.  * routines.
  112.  */
  113. #ifdef  _NTSDK
  114. #ifdef  _DLL
  115. /* Declarations and definitions compatible with the NT SDK */
  116. #define _daylight   (*_daylight_dll)
  117. #define _timezone   (*_timezone_dll)
  118. /* non-zero if daylight savings time is used */
  119. extern int * _daylight_dll;
  120. /* difference in seconds between GMT and local time */
  121. extern long * _timezone_dll;
  122. /* standard/daylight savings time zone names */
  123. extern char ** _tzname;
  124. #else   /* ndef _DLL */
  125. #ifdef  _POSIX_
  126. extern char * _rule;
  127. #endif  /* _POSIX_ */
  128. /* non-zero if daylight savings time is used */
  129. extern int _daylight;
  130. /* difference in seconds between GMT and local time */
  131. extern long _timezone;
  132. /* standard/daylight savings time zone names */
  133. #ifdef  _POSIX_
  134. extern char * tzname[2];
  135. #else   /* ndef _POSIX_ */
  136. extern char * _tzname[2];
  137. #endif  /* _POSIX_ */
  138. #endif  /* _DLL */
  139. #else   /* ndef _NTSDK */
  140. /* Current declarations and definitions */
  141. #if     defined(_DLL) && defined(_M_IX86)
  142. #define _daylight   (*__p__daylight())
  143. _CRTIMP int * __cdecl __p__daylight(void);
  144. #define _dstbias    (*__p__dstbias())
  145. _CRTIMP long * __cdecl __p__dstbias(void);
  146. #define _timezone   (*__p__timezone())
  147. _CRTIMP long * __cdecl __p__timezone(void);
  148. #define _tzname     (__p__tzname())
  149. _CRTIMP char ** __cdecl __p__tzname(void);
  150. #else   /* !(defined(_DLL) && defined(_M_IX86)) */
  151. /* non-zero if daylight savings time is used */
  152. _CRTIMP extern int _daylight;
  153. /* offset for Daylight Saving Time */
  154. _CRTIMP extern long _dstbias;
  155. /* difference in seconds between GMT and local time */
  156. _CRTIMP extern long _timezone;
  157. /* standard/daylight savings time zone names */
  158. _CRTIMP extern char * _tzname[2];
  159. #endif  /* defined(_DLL) && defined(_M_IX86) */
  160. #endif  /* _NTSDK */
  161. /* Function prototypes */
  162. _CRTIMP char * __cdecl asctime(const struct tm *);
  163. _CRTIMP char * __cdecl ctime(const time_t *);
  164. _CRTIMP clock_t __cdecl clock(void);
  165. _CRTIMP double __cdecl difftime(time_t, time_t);
  166. _CRTIMP struct tm * __cdecl gmtime(const time_t *);
  167. _CRTIMP struct tm * __cdecl localtime(const time_t *);
  168. _CRTIMP time_t __cdecl mktime(struct tm *);
  169. _CRTIMP size_t __cdecl strftime(char *, size_t, const char *,
  170.         const struct tm *);
  171. _CRTIMP char * __cdecl _strdate(char *);
  172. _CRTIMP char * __cdecl _strtime(char *);
  173. _CRTIMP time_t __cdecl time(time_t *);
  174. #ifdef  _POSIX_
  175. _CRTIMP void __cdecl tzset(void);
  176. #else
  177. _CRTIMP void __cdecl _tzset(void);
  178. #endif
  179. /* --------- The following functions are OBSOLETE --------- */
  180. /* The Win32 API GetLocalTime and SetLocalTime should be used instead. */
  181. unsigned __cdecl _getsystime(struct tm *);
  182. unsigned __cdecl _setsystime(struct tm *, unsigned);
  183. /* --------- The preceding functions are OBSOLETE --------- */
  184. #ifndef _SIZE_T_DEFINED
  185. typedef unsigned int size_t;
  186. #define _SIZE_T_DEFINED
  187. #endif
  188. #ifndef _MAC
  189. #ifndef _WTIME_DEFINED
  190. /* wide function prototypes, also declared in wchar.h */
  191.  
  192. _CRTIMP wchar_t * __cdecl _wasctime(const struct tm *);
  193. _CRTIMP wchar_t * __cdecl _wctime(const time_t *);
  194. _CRTIMP size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *,
  195.         const struct tm *);
  196. _CRTIMP wchar_t * __cdecl _wstrdate(wchar_t *);
  197. _CRTIMP wchar_t * __cdecl _wstrtime(wchar_t *);
  198. #define _WTIME_DEFINED
  199. #endif
  200. #endif /* ndef _MAC */
  201. #if     !__STDC__ || defined(_POSIX_)
  202. /* Non-ANSI names for compatibility */
  203. #define CLK_TCK  CLOCKS_PER_SEC
  204. #ifdef  _NTSDK
  205. /* Declarations and definitions compatible with the NT SDK */
  206. #define daylight _daylight
  207. /* timezone cannot be #defined because of <sys/timeb.h> */
  208. #ifndef _POSIX_
  209. #define tzname  _tzname
  210. #define tzset   _tzset
  211. #endif /* _POSIX_ */
  212. #else   /* ndef _NTSDK */
  213. #if     defined(_DLL) && defined(_M_IX86)
  214. #define daylight   (*__p__daylight())
  215. /* timezone cannot be #defined because of <sys/timeb.h>
  216.    so CRT DLL for win32s will not have timezone */
  217. _CRTIMP extern long timezone;
  218. #define tzname     (__p__tzname())
  219. #else   /* !(defined(_DLL) && defined(_M_IX86)) */
  220. _CRTIMP extern int daylight;
  221. _CRTIMP extern long timezone;
  222. _CRTIMP extern char * tzname[2];
  223. #endif  /* !(defined(_DLL) && defined(_M_IX86)) */
  224. _CRTIMP void __cdecl tzset(void);
  225. #endif  /* _NTSDK */
  226. #endif  /* __STDC__ */
  227. #ifdef __cplusplus
  228. }
  229. #endif
  230. #ifdef  _MSC_VER
  231. #pragma pack(pop)
  232. #endif  /* _MSC_VER */
  233. #endif  /* _INC_TIME */