4 * Type definitions and function declarations relating to date and time.
8 * Written by Rob Savoye <rob@cygnus.com>
9 * Copyright (C) 1997-2007, 2011, 2015, MinGW.org Project.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice, this permission notice, and the following
20 * disclaimer shall be included in all copies or substantial portions of
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
29 * DEALINGS IN THE SOFTWARE.
35 /* All the headers include this file. */
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
46 * Some elements declared in time.h may also be required by other
47 * header files, without necessarily including time.h itself; such
48 * elements are declared in the local parts/time.h system header file.
49 * Declarations for such elements must be selected prior to inclusion:
52 #define __need_struct_timespec
53 #include <parts/time.h>
55 /* time.h is also required to duplicate the following type definitions,
56 * which are nominally defined in stddef.h
59 #define __need_wchar_t
63 /* A type for measuring processor time in clock ticks; (no need to
64 * guard this, since it isn't defined elsewhere).
70 * A structure for storing all kinds of useful information about the
71 * current (or another) time.
75 int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
76 int tm_min; /* Minutes: 0-59 */
77 int tm_hour; /* Hours since midnight: 0-23 */
78 int tm_mday; /* Day of the month: 1-31 */
79 int tm_mon; /* Months *since* january: 0-11 */
80 int tm_year; /* Years since 1900 */
81 int tm_wday; /* Days since Sunday (0-6) */
82 int tm_yday; /* Days since Jan. 1: 0-365 */
83 int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
91 _CRTIMP clock_t __cdecl __MINGW_NOTHROW clock (void);
92 #if __MSVCRT_VERSION__ < 0x0800
93 _CRTIMP time_t __cdecl __MINGW_NOTHROW time (time_t*);
94 _CRTIMP double __cdecl __MINGW_NOTHROW difftime (time_t, time_t);
95 _CRTIMP time_t __cdecl __MINGW_NOTHROW mktime (struct tm*);
99 * These functions write to and return pointers to static buffers that may
100 * be overwritten by other function calls. Yikes!
102 * NOTE: localtime, and perhaps the others of the four functions grouped
103 * below may return NULL if their argument is not 'acceptable'. Also note
104 * that calling asctime with a NULL pointer will produce an Invalid Page
105 * Fault and crap out your program. Guess how I know. Hint: stat called on
106 * a directory gives 'invalid' times in st_atime etc...
108 _CRTIMP char* __cdecl __MINGW_NOTHROW asctime (const struct tm*);
109 #if __MSVCRT_VERSION__ < 0x0800
110 _CRTIMP char* __cdecl __MINGW_NOTHROW ctime (const time_t*);
111 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t*);
112 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t*);
115 _CRTIMP size_t __cdecl __MINGW_NOTHROW strftime (char*, size_t, const char*, const struct tm*);
117 #ifndef __STRICT_ANSI__
119 extern _CRTIMP void __cdecl __MINGW_NOTHROW _tzset (void);
122 extern _CRTIMP void __cdecl __MINGW_NOTHROW tzset (void);
125 _CRTIMP char* __cdecl __MINGW_NOTHROW _strdate(char*);
126 _CRTIMP char* __cdecl __MINGW_NOTHROW _strtime(char*);
128 /* These require newer versions of msvcrt.dll (6.10 or higher). */
129 #if __MSVCRT_VERSION__ >= 0x0601
130 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _time64( __time64_t*);
131 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mktime64 (struct tm*);
132 _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime64 (const __time64_t*);
133 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime64 (const __time64_t*);
134 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime64 (const __time64_t*);
135 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
137 /* These require newer versions of msvcrt.dll (8.00 or higher). */
138 #if __MSVCRT_VERSION__ >= 0x0800
139 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _time32 (__time32_t*);
140 _CRTIMP double __cdecl __MINGW_NOTHROW _difftime32 (__time32_t, __time32_t);
141 _CRTIMP double __cdecl __MINGW_NOTHROW _difftime64 (__time64_t, __time64_t);
142 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mktime32 (struct tm*);
143 _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mkgmtime32 (struct tm*);
144 _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mkgmtime64 (struct tm*);
145 _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime32 (const __time32_t*);
146 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime32 (const __time32_t*);
147 _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime32 (const __time32_t*);
148 #ifndef _USE_32BIT_TIME_T
149 _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v) { return(_time64 (_v)); }
150 _CRTALIAS double __cdecl __MINGW_NOTHROW difftime (time_t _v1, time_t _v2) { return(_difftime64 (_v1,_v2)); }
151 _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v) { return(_mktime64 (_v)); }
152 _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v) { return(_mkgmtime64 (_v)); }
153 _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v) { return(_ctime64 (_v)); }
154 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v) { return(_gmtime64 (_v)); }
155 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v) { return(_localtime64 (_v)); }
157 _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v) { return(_time32 (_v)); }
158 _CRTALIAS double __cdecl __MINGW_NOTHROW difftime (time_t _v1, time_t _v2) { return(_difftime32 (_v1,_v2)); }
159 _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v) { return(_mktime32 (_v)); }
160 _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v) { return(_mkgmtime32 (_v)); }
161 _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v) { return(_ctime32 (_v)); }
162 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v) { return(_gmtime32 (_v)); }
163 _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v) { return(_localtime32 (_v)); }
164 #endif /* !_USE_32BIT_TIME_T */
165 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
167 /* _daylight: non zero if daylight savings time is used.
168 * _timezone: difference in seconds between GMT and local time.
169 * _tzname: standard/daylight savings time zone names (an array with two
174 /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
175 extern _CRTIMP int* __cdecl __MINGW_NOTHROW __p__daylight (void);
176 extern _CRTIMP long* __cdecl __MINGW_NOTHROW __p__timezone (void);
177 extern _CRTIMP char** __cdecl __MINGW_NOTHROW __p__tzname (void);
179 __MINGW_IMPORT int _daylight;
180 __MINGW_IMPORT long _timezone;
181 __MINGW_IMPORT char *_tzname[2];
183 #else /* not __MSVCRT (ie. crtdll) */
185 #ifndef __DECLSPEC_SUPPORTED
187 extern int* _imp___daylight_dll;
188 extern long* _imp___timezone_dll;
189 extern char** _imp___tzname;
191 #define _daylight (*_imp___daylight_dll)
192 #define _timezone (*_imp___timezone_dll)
193 #define _tzname (*_imp___tzname)
195 #else /* __DECLSPEC_SUPPORTED */
197 __MINGW_IMPORT int _daylight_dll;
198 __MINGW_IMPORT long _timezone_dll;
199 __MINGW_IMPORT char* _tzname[2];
201 #define _daylight _daylight_dll
202 #define _timezone _timezone_dll
204 #endif /* __DECLSPEC_SUPPORTED */
205 #endif /* ! __MSVCRT__ */
206 #endif /* ! __STRICT_ANSI__ */
211 /* These go in the oldnames import library for MSVCRT.
213 __MINGW_IMPORT int daylight;
214 __MINGW_IMPORT long timezone;
215 __MINGW_IMPORT char *tzname[2];
217 #else /* ! __MSVCRT__ */
219 * CRTDLL is royally messed up when it comes to these macros.
220 * TODO: import and alias these via oldnames import library instead
223 #define daylight _daylight
225 * NOTE: timezone not defined as a macro because it would conflict with
226 * struct timezone in sys/time.h. Also, tzname used to a be macro, but
227 * now it's in moldname.
229 __MINGW_IMPORT char *tzname[2];
231 #endif /* ! __MSVCRT__ */
232 #endif /* ! _NO_OLDNAMES */
234 #ifndef _WTIME_DEFINED
235 /* wide function prototypes, also declared in wchar.h */
236 #ifndef __STRICT_ANSI__
238 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wasctime(const struct tm*);
239 #if __MSVCRT_VERSION__ < 0x0800
240 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime(const time_t*);
242 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrdate(wchar_t*);
243 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrtime(wchar_t*);
244 #if __MSVCRT_VERSION__ >= 0x0601
245 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime64 (const __time64_t*);
247 #if __MSVCRT_VERSION__ >= 0x0800
248 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime32 (const __time32_t*);
249 #ifndef _USE_32BIT_TIME_T
250 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime64 (_v)); }
252 _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime32 (_v)); }
254 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
255 #endif /* __MSVCRT__ */
256 #endif /* __STRICT_ANSI__ */
257 _CRTIMP size_t __cdecl __MINGW_NOTHROW wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
258 #define _WTIME_DEFINED
259 #endif /* _WTIME_DEFINED */
263 #endif /* ! RC_INVOKED */
264 #endif /* ! _TIME_H: $RCSfile$: end of file */