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.
7 * Date and time functions and types.
14 /* All the headers include this file. */
17 #define __need_wchar_t
22 #endif /* Not RC_INVOKED */
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'.
28 #define CLOCKS_PER_SEC ((clock_t)1000)
29 #define CLK_TCK CLOCKS_PER_SEC
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.
39 #ifndef _TIME32_T_DEFINED
40 typedef __int32 __time32_t;
41 #define _TIME32_T_DEFINED
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
52 #ifndef _TIME_T_DEFINED
53 /* FIXME __STRICT_ANSI__ ! */
54 #if __MSVCRT_VERSION__ >= 0x0800
55 #ifndef _USE_32BIT_TIME_T
56 typedef __time64_t time_t;
58 typedef __time32_t time_t;
59 #endif /* !_USE_32BIT_TIME_T */
61 typedef __time32_t time_t;
62 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
63 #define _TIME_T_DEFINED
68 * A type for measuring processor time (in clock ticks).
70 #ifndef _CLOCK_T_DEFINED
72 #define _CLOCK_T_DEFINED
77 * A structure for storing all kinds of useful information about the
78 * current (or another) time.
82 int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
83 int tm_min; /* Minutes: 0-59 */
84 int tm_hour; /* Hours since midnight: 0-23 */
85 int tm_mday; /* Day of the month: 1-31 */
86 int tm_mon; /* Months *since* january: 0-11 */
87 int tm_year; /* Years since 1900 */
88 int tm_wday; /* Days since Sunday (0-6) */
89 int tm_yday; /* Days since Jan. 1: 0-365 */
90 int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
100 _CRTIMP clock_t __cdecl __MINGW_NOTHROW clock (void);
101 #if __MSVCRT_VERSION__ < 0x0800
102 _CRTIMP time_t __cdecl __MINGW_NOTHROW time (time_t*);
103 _CRTIMP double __cdecl __MINGW_NOTHROW difftime (time_t, time_t);
104 _CRTIMP time_t __cdecl __MINGW_NOTHROW mktime (struct tm*);
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 #if __MSVCRT_VERSION__ < 0x0800
119 _CRTIMP char* __cdecl __MINGW_NOTHROW ctime (const time_t*);
120 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t*);
121 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t*);
124 _CRTIMP size_t __cdecl __MINGW_NOTHROW strftime (char*, size_t, const char*, const struct tm*);
126 #ifndef __STRICT_ANSI__
128 extern _CRTIMP void __cdecl __MINGW_NOTHROW _tzset (void);
131 extern _CRTIMP void __cdecl __MINGW_NOTHROW tzset (void);
134 _CRTIMP char* __cdecl __MINGW_NOTHROW _strdate(char*);
135 _CRTIMP char* __cdecl __MINGW_NOTHROW _strtime(char*);
137 /* These require newer versions of msvcrt.dll (6.10 or higher). */
138 #if __MSVCRT_VERSION__ >= 0x0601
139 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _time64( __time64_t*);
140 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mktime64 (struct tm*);
141 _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime64 (const __time64_t*);
142 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime64 (const __time64_t*);
143 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime64 (const __time64_t*);
144 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
146 /* These require newer versions of msvcrt.dll (8.00 or higher). */
147 #if __MSVCRT_VERSION__ >= 0x0800
148 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _time32 (__time32_t*);
149 _CRTIMP double __cdecl __MINGW_NOTHROW _difftime32 (__time32_t, __time32_t);
150 _CRTIMP double __cdecl __MINGW_NOTHROW _difftime64 (__time64_t, __time64_t);
151 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mktime32 (struct tm*);
152 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mkgmtime32 (struct tm*);
153 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mkgmtime64 (struct tm*);
154 _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime32 (const __time32_t*);
155 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime32 (const __time32_t*);
156 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime32 (const __time32_t*);
157 #ifndef _USE_32BIT_TIME_T
158 _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v) { return(_time64 (_v)); }
159 _CRTALIAS double __cdecl __MINGW_NOTHROW difftime (time_t _v1, time_t _v2) { return(_difftime64 (_v1,_v2)); }
160 _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v) { return(_mktime64 (_v)); }
161 _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v) { return(_mkgmtime64 (_v)); }
162 _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v) { return(_ctime64 (_v)); }
163 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v) { return(_gmtime64 (_v)); }
164 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v) { return(_localtime64 (_v)); }
166 _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v) { return(_time32 (_v)); }
167 _CRTALIAS double __cdecl __MINGW_NOTHROW difftime (time_t _v1, time_t _v2) { return(_difftime32 (_v1,_v2)); }
168 _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v) { return(_mktime32 (_v)); }
169 _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v) { return(_mkgmtime32 (_v)); }
170 _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v) { return(_ctime32 (_v)); }
171 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v) { return(_gmtime32 (_v)); }
172 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v) { return(_localtime32 (_v)); }
173 #endif /* !_USE_32BIT_TIME_T */
174 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
178 * _daylight: non zero if daylight savings time is used.
179 * _timezone: difference in seconds between GMT and local time.
180 * _tzname: standard/daylight savings time zone names (an array with two
185 /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
186 extern _CRTIMP int* __cdecl __MINGW_NOTHROW __p__daylight (void);
187 extern _CRTIMP long* __cdecl __MINGW_NOTHROW __p__timezone (void);
188 extern _CRTIMP char** __cdecl __MINGW_NOTHROW __p__tzname (void);
190 __MINGW_IMPORT int _daylight;
191 __MINGW_IMPORT long _timezone;
192 __MINGW_IMPORT char *_tzname[2];
194 #else /* not __MSVCRT (ie. crtdll) */
196 #ifndef __DECLSPEC_SUPPORTED
198 extern int* _imp___daylight_dll;
199 extern long* _imp___timezone_dll;
200 extern char** _imp___tzname;
202 #define _daylight (*_imp___daylight_dll)
203 #define _timezone (*_imp___timezone_dll)
204 #define _tzname (*_imp___tzname)
206 #else /* __DECLSPEC_SUPPORTED */
208 __MINGW_IMPORT int _daylight_dll;
209 __MINGW_IMPORT long _timezone_dll;
210 __MINGW_IMPORT char* _tzname[2];
212 #define _daylight _daylight_dll
213 #define _timezone _timezone_dll
215 #endif /* __DECLSPEC_SUPPORTED */
217 #endif /* not __MSVCRT__ */
219 #endif /* Not __STRICT_ANSI__ */
225 /* These go in the oldnames import library for MSVCRT. */
226 __MINGW_IMPORT int daylight;
227 __MINGW_IMPORT long timezone;
228 __MINGW_IMPORT char *tzname[2];
230 #else /* not __MSVCRT__ */
232 /* CRTDLL is royally messed up when it comes to these macros.
233 TODO: import and alias these via oldnames import library instead
236 #define daylight _daylight
237 /* NOTE: timezone not defined as macro because it would conflict with
238 struct timezone in sys/time.h.
239 Also, tzname used to a be macro, but now it's in moldname. */
240 __MINGW_IMPORT char *tzname[2];
242 #endif /* not __MSVCRT__ */
244 #endif /* Not _NO_OLDNAMES */
246 #ifndef _WTIME_DEFINED
247 /* wide function prototypes, also declared in wchar.h */
248 #ifndef __STRICT_ANSI__
250 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wasctime(const struct tm*);
251 #if __MSVCRT_VERSION__ < 0x0800
252 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime(const time_t*);
254 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrdate(wchar_t*);
255 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrtime(wchar_t*);
256 #if __MSVCRT_VERSION__ >= 0x0601
257 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime64 (const __time64_t*);
259 #if __MSVCRT_VERSION__ >= 0x0800
260 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime32 (const __time32_t*);
261 #ifndef _USE_32BIT_TIME_T
262 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime64 (_v)); }
264 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime32 (_v)); }
266 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
267 #endif /* __MSVCRT__ */
268 #endif /* __STRICT_ANSI__ */
269 _CRTIMP size_t __cdecl __MINGW_NOTHROW wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
270 #define _WTIME_DEFINED
271 #endif /* _WTIME_DEFINED */
277 #endif /* Not RC_INVOKED */
279 #endif /* Not _TIME_H_ */