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