3 * Copyright 2012, 2013 MinGW.org project
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
26 #pragma GCC system_header
29 #define __need_wchar_t
35 #endif /* Not RC_INVOKED */
38 * Number of clock ticks per second. A clock tick is the unit by which
39 * processor time is measured and is returned by 'clock'.
41 #define CLOCKS_PER_SEC ((clock_t)1000)
42 #define CLK_TCK CLOCKS_PER_SEC
48 * A type for storing the current time and date. This is the number of
49 * seconds since midnight Jan 1, 1970.
50 * NOTE: This is also defined in non-ISO sys/types.h.
52 #ifndef _TIME32_T_DEFINED
53 typedef __int32 __time32_t;
54 #define _TIME32_T_DEFINED
57 #ifndef _TIME64_T_DEFINED
58 /* A 64-bit time_t to get to Y3K */
59 typedef __int64 __time64_t;
60 #define _TIME64_T_DEFINED
63 #ifndef _TIME_T_DEFINED
64 # if defined(_USE_32BIT_TIME_T)
65 typedef __time32_t time_t;
67 typedef __time64_t time_t;
68 # endif /* _USE_32BIT_TIME_T */
69 # define _TIME_T_DEFINED
73 * A type for measuring processor time (in clock ticks).
75 #ifndef _CLOCK_T_DEFINED
77 #define _CLOCK_T_DEFINED
82 * A structure for storing all kinds of useful information about the
83 * current (or another) time.
87 int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
88 int tm_min; /* Minutes: 0-59 */
89 int tm_hour; /* Hours since midnight: 0-23 */
90 int tm_mday; /* Day of the month: 1-31 */
91 int tm_mon; /* Months *since* january: 0-11 */
92 int tm_year; /* Years since 1900 */
93 int tm_wday; /* Days since Sunday (0-6) */
94 int tm_yday; /* Days since Jan. 1: 0-365 */
95 int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
105 _CRTIMP clock_t __cdecl __MINGW_NOTHROW clock (void);
108 * These functions write to and return pointers to static buffers that may
109 * be overwritten by other function calls. Yikes!
111 * NOTE: localtime, and perhaps the others of the four functions grouped
112 * below may return NULL if their argument is not 'acceptable'. Also note
113 * that calling asctime with a NULL pointer will produce an Invalid Page
114 * Fault and crap out your program. Guess how I know. Hint: stat called on
115 * a directory gives 'invalid' times in st_atime etc...
117 _CRTIMP char* __cdecl __MINGW_NOTHROW asctime (const struct tm*);
118 _CRTIMP size_t __cdecl __MINGW_NOTHROW strftime (char*, size_t, const char*, const struct tm*);
119 #if MSVCRT_VERSION < 800
120 _CRTIMP char* __cdecl __MINGW_NOTHROW ctime (const time_t*);
121 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t*);
122 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t*);
124 _CRTIMP time_t __cdecl __MINGW_NOTHROW time (time_t*);
125 _CRTIMP double __cdecl __MINGW_NOTHROW difftime (time_t, time_t);
126 _CRTIMP time_t __cdecl __MINGW_NOTHROW mktime (struct tm*);
129 #ifndef __STRICT_ANSI__
131 extern _CRTIMP void __cdecl __MINGW_NOTHROW _tzset (void);
134 extern _CRTIMP void __cdecl __MINGW_NOTHROW tzset (void);
137 _CRTIMP char* __cdecl __MINGW_NOTHROW _strdate(char*);
138 _CRTIMP char* __cdecl __MINGW_NOTHROW _strtime(char*);
140 /* These require newer versions of msvcrt.dll (6.10 or higher). */
141 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _time64( __time64_t*);
142 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mktime64 (struct tm*);
143 _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime64 (const __time64_t*);
144 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime64 (const __time64_t*);
145 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime64 (const __time64_t*);
147 /* These require newer versions of msvcrt.dll (8.00 or higher). */
148 #if MSVCRT_VERSION >= 800
149 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _time32 (__time32_t*);
150 _CRTIMP double __cdecl __MINGW_NOTHROW _difftime32 (__time32_t, __time32_t);
151 _CRTIMP double __cdecl __MINGW_NOTHROW _difftime64 (__time64_t, __time64_t);
152 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mktime32 (struct tm*);
153 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mkgmtime32 (struct tm*);
154 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mkgmtime64 (struct tm*);
155 _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime32 (const __time32_t*);
156 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime32 (const __time32_t*);
157 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime32(const __time32_t*);
158 #else /* MSVCRT_VERSION < 800 */
159 _CRTALIAS __time32_t __cdecl __MINGW_NOTHROW _time32 (__time32_t *_v) {
160 return ((__time32_t)time((time_t)_v));
162 _CRTALIAS double __cdecl __MINGW_NOTHROW _difftime32 (__time32_t _v1, __time32_t _v2) {
163 return (difftime((time_t)_v1, (time_t)_v2));
165 _CRTALIAS __time32_t __cdecl __MINGW_NOTHROW _mktime32(struct tm* _v1) {
166 return ((__time32_t)mktime(_v1));
168 _CRTALIAS char* __cdecl __MINGW_NOTHROW _ctime32(const __time32_t* _v1) {
169 return (ctime((time_t)_v1));
171 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW _gmtime32(const __time32_t* _v1) {
172 return (gmtime((time_t)_v1));
174 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW _localtime32(const __time32_t* _v1) {
175 return (localtime((time_t)_v1));
177 #endif /* MSVCRT_VERSION >= 800 */
179 #if defined(_USE_32BIT_TIME_T)
180 /* Prevent circular recursion. */
181 #if MSVCRT_VERSION >= 800
182 _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v)
183 { return(_time32 (_v)); }
184 _CRTALIAS double __cdecl __MINGW_NOTHROW difftime(time_t _v1, time_t _v2)
185 { return(_difftime32 (_v1,_v2)); }
186 _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v)
187 { return(_mktime32 (_v)); }
188 _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v)
189 { return(_mkgmtime32 (_v)); }
190 _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v)
191 { return(_ctime32 (_v)); }
192 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v)
193 { return(_gmtime32 (_v)); }
194 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v)
195 { return(_localtime32 (_v)); }
196 #endif /* MSVCRT_VERSION >= 800 */
198 #else /* !defined(_USE_32BIT_TIME_T) */
199 /* _difftime64 and _mkgmtime64 are missing from MSVCRT.DLL pre Vista. */
200 #if MSVCRT_VERSION >= 800
201 _CRTALIAS double __cdecl __MINGW_NOTHROW difftime(time_t _v1, time_t _v2)
202 { return(_difftime64 (_v1,_v2)); }
203 _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v)
204 { return(_mkgmtime64 (_v)); }
205 #endif /* MSVCRT_VERSION >= 800 */
206 _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v)
207 { return(_time64 (_v)); }
208 _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v)
209 { return(_mktime64 (_v)); }
210 _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v)
211 { return(_ctime64 (_v)); }
212 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v)
213 { return(_gmtime64 (_v)); }
214 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v)
215 { return(_localtime64 (_v)); }
216 #endif /* _USE_32BIT_TIME_T */
219 * _daylight: non zero if daylight savings time is used.
220 * _timezone: difference in seconds between GMT and local time.
221 * _tzname: standard/daylight savings time zone names (an array with two
225 /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
226 extern _CRTIMP int* __cdecl __MINGW_NOTHROW __p__daylight (void);
227 extern _CRTIMP long* __cdecl __MINGW_NOTHROW __p__timezone (void);
228 extern _CRTIMP char** __cdecl __MINGW_NOTHROW __p__tzname (void);
230 __MINGW_IMPORT int _daylight;
231 __MINGW_IMPORT long _timezone;
232 __MINGW_IMPORT char *_tzname[2];
234 #endif /* Not __STRICT_ANSI__ */
237 /* These go in the oldnames import library for MSVCRT. */
238 __MINGW_IMPORT int daylight;
239 __MINGW_IMPORT long timezone;
240 __MINGW_IMPORT char *tzname[2];
241 #endif /* Not _NO_OLDNAMES */
243 #ifndef _WTIME_DEFINED
244 /* wide function prototypes, also declared in wchar.h */
246 #ifndef __STRICT_ANSI__
247 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wasctime(const struct tm*);
248 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrdate(wchar_t*);
249 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrtime(wchar_t*);
250 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime64(const __time64_t*);
251 #if MSVCRT_VERSION >= 800
252 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime32(const __time32_t*);
254 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime(const time_t*);
255 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime32(const __time32_t* _v) {
256 return(_wctime((time_t)_v));
258 #endif /* MSVCRT_VERSION >= 800 */
260 #ifdef _USE_32BIT_TIME_T
261 #if MSVCRT_VERSION >= 800
262 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) {
263 return(_wctime32 (_v));
266 #else /* ndef _USE_32BIT_TIME_T */
267 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) {
268 return(_wctime64 (_v));
270 #endif /* def _USE_32BIT_TIME_T */
272 #endif /* __STRICT_ANSI__ */
274 _CRTIMP size_t __cdecl __MINGW_NOTHROW wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
275 #define _WTIME_DEFINED
276 #endif /* _WTIME_DEFINED */
282 #endif /* Not RC_INVOKED */
284 #endif /* Not _TIME_H */