Add a script to make it easier to initialize /.git
[msysgit/historical-msysgit.git] / mingw / include / time.h
blob13d4d1630b3e75f4589b99c24ef5deefeb953327
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.
7 * Date and time functions and types.
9 */
11 #ifndef _TIME_H_
12 #define _TIME_H_
14 /* All the headers include this file. */
15 #include <_mingw.h>
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 */
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
32 #ifndef RC_INVOKED
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 _TIME_T_DEFINED
40 typedef long time_t;
41 #define _TIME_T_DEFINED
42 #endif
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
52 * A type for measuring processor time (in clock ticks).
54 #ifndef _CLOCK_T_DEFINED
55 typedef long clock_t;
56 #define _CLOCK_T_DEFINED
57 #endif
59 #ifndef _TM_DEFINED
61 * A structure for storing all kinds of useful information about the
62 * current (or another) time.
64 struct tm
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 */
77 #define _TM_DEFINED
78 #endif
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
84 _CRTIMP clock_t __cdecl clock (void);
85 _CRTIMP time_t __cdecl time (time_t*);
86 _CRTIMP double __cdecl difftime (time_t, time_t);
87 _CRTIMP time_t __cdecl mktime (struct tm*);
90 * These functions write to and return pointers to static buffers that may
91 * be overwritten by other function calls. Yikes!
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...
99 _CRTIMP char* __cdecl asctime (const struct tm*);
100 _CRTIMP char* __cdecl ctime (const time_t*);
101 _CRTIMP struct tm* __cdecl gmtime (const time_t*);
102 _CRTIMP struct tm* __cdecl localtime (const time_t*);
104 _CRTIMP size_t __cdecl strftime (char*, size_t, const char*, const struct tm*);
106 #ifndef __STRICT_ANSI__
108 extern _CRTIMP void __cdecl _tzset (void);
110 #ifndef _NO_OLDNAMES
111 extern _CRTIMP void __cdecl tzset (void);
112 #endif
114 _CRTIMP char* __cdecl _strdate(char*);
115 _CRTIMP char* __cdecl _strtime(char*);
117 /* These require newer versions of msvcrt.dll (6.10 or higher). */
118 #if __MSVCRT_VERSION__ >= 0x0601
119 _CRTIMP __time64_t __cdecl _time64( __time64_t*);
120 _CRTIMP __time64_t __cdecl _mktime64 (struct tm*);
121 _CRTIMP char* __cdecl _ctime64 (const __time64_t*);
122 _CRTIMP struct tm* __cdecl _gmtime64 (const __time64_t*);
123 _CRTIMP struct tm* __cdecl _localtime64 (const __time64_t*);
124 #endif /* __MSVCRT_VERSION__ >= 0x0601 */
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).
132 #ifdef __MSVCRT__
134 /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
135 extern _CRTIMP int* __cdecl __p__daylight (void);
136 extern _CRTIMP long* __cdecl __p__timezone (void);
137 extern _CRTIMP char** __cdecl __p__tzname (void);
139 __MINGW_IMPORT int _daylight;
140 __MINGW_IMPORT long _timezone;
141 __MINGW_IMPORT char *_tzname[2];
143 #else /* not __MSVCRT (ie. crtdll) */
145 #ifndef __DECLSPEC_SUPPORTED
147 extern int* _imp___daylight_dll;
148 extern long* _imp___timezone_dll;
149 extern char** _imp___tzname;
151 #define _daylight (*_imp___daylight_dll)
152 #define _timezone (*_imp___timezone_dll)
153 #define _tzname (*_imp___tzname)
155 #else /* __DECLSPEC_SUPPORTED */
157 __MINGW_IMPORT int _daylight_dll;
158 __MINGW_IMPORT long _timezone_dll;
159 __MINGW_IMPORT char* _tzname[2];
161 #define _daylight _daylight_dll
162 #define _timezone _timezone_dll
164 #endif /* __DECLSPEC_SUPPORTED */
166 #endif /* not __MSVCRT__ */
168 #ifndef _NO_OLDNAMES
170 #ifdef __MSVCRT__
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];
177 #else /* not __MSVCRT__ */
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. */
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];
189 #endif /* not __MSVCRT__ */
191 #endif /* Not _NO_OLDNAMES */
192 #endif /* Not __STRICT_ANSI__ */
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 _wasctime(const struct tm*);
199 _CRTIMP wchar_t* __cdecl _wctime(const time_t*);
200 _CRTIMP wchar_t* __cdecl _wstrdate(wchar_t*);
201 _CRTIMP wchar_t* __cdecl _wstrtime(wchar_t*);
202 #if __MSVCRT_VERSION__ >= 0x0601
203 _CRTIMP wchar_t* __cdecl _wctime64 (const __time64_t*);
204 #endif
205 #endif /* __MSVCRT__ */
206 #endif /* __STRICT_ANSI__ */
207 _CRTIMP size_t __cdecl wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
208 #define _WTIME_DEFINED
209 #endif /* _WTIME_DEFINED */
211 #ifdef __cplusplus
213 #endif
215 #endif /* Not RC_INVOKED */
217 #endif /* Not _TIME_H_ */