xref: /reactos/sdk/include/crt/time.h (revision 1734f297)
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the w64 mingw-runtime package.
4  * No warranty is given; refer to the file DISCLAIMER within this package.
5  */
6 
7 #ifndef _TIME_H_
8 #define _TIME_H_
9 
10 #include <crtdefs.h>
11 
12 #ifndef _WIN32
13 #error Only Win32 target is supported!
14 #endif
15 
16 #pragma pack(push,_CRT_PACKING)
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #ifndef _TIME32_T_DEFINED
23 #define _TIME32_T_DEFINED
24   typedef long __time32_t;
25 #endif
26 
27 #ifndef _TIME64_T_DEFINED
28 #define _TIME64_T_DEFINED
29 #if _INTEGRAL_MAX_BITS >= 64
30 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
31   typedef int _time64_t __attribute__ ((mode (DI)));
32 #else
33   __MINGW_EXTENSION typedef __int64 __time64_t;
34 #endif
35 #endif
36 #endif
37 
38 #ifndef _TIME_T_DEFINED
39 #define _TIME_T_DEFINED
40 #ifdef _USE_32BIT_TIME_T
41   typedef __time32_t time_t;
42 #else
43   typedef __time64_t time_t;
44 #endif
45 #endif
46 
47 #ifndef _CLOCK_T_DEFINED
48 #define _CLOCK_T_DEFINED
49   typedef long clock_t;
50 #endif
51 
52 #ifndef _SIZE_T_DEFINED
53 #define _SIZE_T_DEFINED
54 #undef size_t
55 #ifdef _WIN64
56 #if defined(__GNUC__) && defined(__STRICT_ANSI__)
57   typedef unsigned int size_t __attribute__ ((mode (DI)));
58 #else
59   __MINGW_EXTENSION typedef unsigned __int64 size_t;
60 #endif
61 #else
62   typedef unsigned int size_t;
63 #endif
64 #endif
65 
66 #ifndef _TM_DEFINED
67 #define _TM_DEFINED
68   struct tm {
69     int tm_sec;
70     int tm_min;
71     int tm_hour;
72     int tm_mday;
73     int tm_mon;
74     int tm_year;
75     int tm_wday;
76     int tm_yday;
77     int tm_isdst;
78   };
79 #endif
80 
81 #define CLOCKS_PER_SEC 1000
82 
83   _CRTDATA(extern int _daylight);
84   _CRTDATA(extern long _dstbias);
85   _CRTDATA(extern long _timezone);
86   _CRTDATA(extern char * _tzname[2]);
87 
88   _CRTIMP errno_t __cdecl _get_daylight(_Out_ int *_Daylight);
89   _CRTIMP errno_t __cdecl _get_dstbias(_Out_ long *_Daylight_savings_bias);
90   _CRTIMP errno_t __cdecl _get_timezone(_Out_ long *_Timezone);
91 
92   _CRTIMP
93   errno_t
94   __cdecl
95   _get_tzname(
96     _Out_ size_t *_ReturnValue,
97     _Out_writes_z_(_SizeInBytes) char *_Buffer,
98     _In_ size_t _SizeInBytes,
99     _In_ int _Index);
100 
101   _Check_return_
102   _CRTIMP
103   _CRT_INSECURE_DEPRECATE(asctime_s)
104   char *
105   __cdecl
106   asctime(
107     _In_ const struct tm *_Tm);
108 
109   _CRTIMP
110   _CRT_INSECURE_DEPRECATE(_ctime32_s)
111   char *
112   __cdecl
113   _ctime32(
114     _In_ const __time32_t *_Time);
115 
116   _Check_return_ _CRTIMP clock_t __cdecl clock(void);
117 
118   _CRTIMP
119   double
120   __cdecl
121   _difftime32(
122     _In_ __time32_t _Time1,
123     _In_ __time32_t _Time2);
124 
125   _Check_return_
126   _CRTIMP
127   _CRT_INSECURE_DEPRECATE(_gmtime32_s)
128   struct tm *
129   __cdecl
130   _gmtime32(
131     _In_ const __time32_t *_Time);
132 
133   _CRTIMP
134   _CRT_INSECURE_DEPRECATE(_localtime32_s)
135   struct tm *
136   __cdecl
137   _localtime32(
138     _In_ const __time32_t *_Time);
139 
140   _Success_(return > 0)
141   _CRTIMP
142   size_t
143   __cdecl
144   strftime(
145     _Out_writes_z_(_SizeInBytes) char *_Buf,
146     _In_ size_t _SizeInBytes,
147     _In_z_ _Printf_format_string_ const char *_Format,
148     _In_ const struct tm *_Tm);
149 
150   _Success_(return > 0)
151   _CRTIMP
152   size_t
153   __cdecl
154   _strftime_l(
155     _Out_writes_z_(_Max_size) char *_Buf,
156     _In_ size_t _Max_size,
157     _In_z_ _Printf_format_string_ const char *_Format,
158     _In_ const struct tm *_Tm,
159     _In_opt_ _locale_t _Locale);
160 
161   _CRTIMP char *__cdecl _strdate(_Out_writes_z_(9) char *_Buffer);
162   _CRTIMP char *__cdecl _strtime(_Out_writes_z_(9) char *_Buffer);
163   _CRTIMP __time32_t __cdecl _time32(_Out_opt_ __time32_t *_Time);
164   _CRTIMP __time32_t __cdecl _mktime32(_Inout_ struct tm *_Tm);
165   _CRTIMP __time32_t __cdecl _mkgmtime32(_Inout_ struct tm *_Tm);
166   _CRTIMP void __cdecl _tzset(void);
167   _CRT_OBSOLETE(GetLocalTime) unsigned __cdecl _getsystime(_Out_ struct tm *_Tm);
168 
169   _CRT_OBSOLETE(GetLocalTime)
170   unsigned
171   __cdecl
172   _setsystime(
173     _In_ struct tm *_Tm,
174     unsigned _MilliSec);
175 
176   _Check_return_wat_
177   _CRTIMP
178   errno_t
179   __cdecl
180   asctime_s(
181     _Out_writes_(_SizeInBytes) _Post_readable_size_(26) char *_Buf,
182     _In_range_(>= , 26) size_t _SizeInBytes,
183     _In_ const struct tm *_Tm);
184 
185   _Success_(return == 0)
186   _CRTIMP
187   errno_t
188   __cdecl
189   _ctime32_s(
190     _Out_writes_(_SizeInBytes) _Post_readable_size_(26) char *_Buf,
191     _In_ size_t _SizeInBytes,
192     _In_ const __time32_t *_Time);
193 
194   _Check_return_wat_
195   _CRTIMP
196   errno_t
197   __cdecl
198   _gmtime32_s(
199     _In_ struct tm *_Tm,
200     _In_ const __time32_t *_Time);
201 
202   _CRTIMP
203   errno_t
204   __cdecl
205   _localtime32_s(
206     _Out_ struct tm *_Tm,
207     _In_ const __time32_t *_Time);
208 
209   _Check_return_wat_
210   _CRTIMP
211   errno_t
212   __cdecl
213   _strdate_s(
214     _Out_writes_(_SizeInBytes) _Post_readable_size_(9) char *_Buf,
215     _In_range_(>= , 9) size_t _SizeInBytes);
216 
217   _Check_return_wat_
218   _CRTIMP
219   errno_t
220   __cdecl
221   _strtime_s(
222     _Out_writes_(_SizeInBytes) _Post_readable_size_(9) char *_Buf,
223     _In_range_(>= , 9) size_t _SizeInBytes);
224 
225 #if _INTEGRAL_MAX_BITS >= 64
226 
227   _Check_return_
228   _CRTIMP
229   double
230   __cdecl
231   _difftime64(
232     _In_ __time64_t _Time1,
233     _In_ __time64_t _Time2);
234 
235   _CRTIMP
236   _CRT_INSECURE_DEPRECATE(_ctime64_s)
237   char *
238   __cdecl
239   _ctime64(
240     _In_ const __time64_t *_Time);
241 
242   _CRTIMP
243   _CRT_INSECURE_DEPRECATE(_gmtime64_s)
244   struct tm *
245   __cdecl
246   _gmtime64(
247     _In_ const __time64_t *_Time);
248 
249   _CRTIMP
250   _CRT_INSECURE_DEPRECATE(_localtime64_s)
251   struct tm *
252   __cdecl
253   _localtime64(
254     _In_ const __time64_t *_Time);
255 
256   _CRTIMP __time64_t __cdecl _mktime64(_Inout_ struct tm *_Tm);
257   _CRTIMP __time64_t __cdecl _mkgmtime64(_Inout_ struct tm *_Tm);
258   _CRTIMP __time64_t __cdecl _time64(_Out_opt_ __time64_t *_Time);
259 
260   _CRTIMP
261   errno_t
262   __cdecl
263   _ctime64_s(
264     _Out_writes_z_(_SizeInBytes) char *_Buf,
265     _In_ size_t _SizeInBytes,
266     _In_ const __time64_t *_Time);
267 
268   _CRTIMP
269   errno_t
270   __cdecl
271   _gmtime64_s(
272     _Out_ struct tm *_Tm,
273     _In_ const __time64_t *_Time);
274 
275   _CRTIMP
276   errno_t
277   __cdecl
278   _localtime64_s(
279     _Out_ struct tm *_Tm,
280     _In_ const __time64_t *_Time);
281 
282 #endif /* _INTEGRAL_MAX_BITS >= 64 */
283 
284 #ifndef _WTIME_DEFINED
285 #define _WTIME_DEFINED
286 
287   _CRTIMP
288   _CRT_INSECURE_DEPRECATE(_wasctime_s)
289   wchar_t *
290   __cdecl
291   _wasctime(
292     _In_ const struct tm *_Tm);
293 
294   _CRTIMP wchar_t *__cdecl _wctime(const time_t *_Time);
295 
296   _CRTIMP
297   _CRT_INSECURE_DEPRECATE(_wctime32_s)
298   wchar_t *
299   __cdecl
300   _wctime32(
301     _In_ const __time32_t *_Time);
302 
303   _Success_(return > 0)
304   _CRTIMP
305   size_t
306   __cdecl
307   wcsftime(
308     _Out_writes_z_(_SizeInWords) wchar_t *_Buf,
309     _In_ size_t _SizeInWords,
310     _In_z_ _Printf_format_string_ const wchar_t *_Format,
311     _In_ const struct tm *_Tm);
312 
313   _Success_(return > 0)
314   _CRTIMP
315   size_t
316   __cdecl
317   _wcsftime_l(
318     _Out_writes_z_(_SizeInWords) wchar_t *_Buf,
319     _In_ size_t _SizeInWords,
320     _In_z_ _Printf_format_string_ const wchar_t *_Format,
321     _In_ const struct tm *_Tm,
322     _In_opt_ _locale_t _Locale);
323 
324   _CRTIMP wchar_t *__cdecl _wstrdate(_Out_writes_z_(9) wchar_t *_Buffer);
325   _CRTIMP wchar_t *__cdecl _wstrtime(_Out_writes_z_(9) wchar_t *_Buffer);
326 
327   _CRTIMP
328   errno_t
329   __cdecl
330   _wasctime_s(
331     _Out_writes_(_SizeInWords) _Post_readable_size_(26) wchar_t *_Buf,
332     _In_range_(>= , 26) size_t _SizeInWords,
333     _In_ const struct tm *_Tm);
334 
335   _Success_(return == 0)
336   _CRTIMP
337   errno_t
338   __cdecl
339   _wctime32_s(
340     _Out_writes_(_SizeInWords) _Post_readable_size_(26) wchar_t *_Buf,
341     _In_ size_t _SizeInWords,
342     _In_ const __time32_t *_Time);
343 
344   _CRTIMP
345   errno_t
346   __cdecl
347   _wstrdate_s(
348     _Out_writes_(_SizeInWords) _Post_readable_size_(9) wchar_t *_Buf,
349     _In_ size_t _SizeInWords);
350 
351   _CRTIMP
352   errno_t
353   __cdecl
354   _wstrtime_s(
355     _Out_writes_(_SizeInWords) _Post_readable_size_(9) wchar_t *_Buf,
356     _In_range_(>= , 9) size_t _SizeInWords);
357 
358 #if _INTEGRAL_MAX_BITS >= 64
359 
360   _CRTIMP
361   _CRT_INSECURE_DEPRECATE(_wctime64_s)
362   wchar_t *
363   __cdecl
364   _wctime64(
365     _In_ const __time64_t *_Time);
366 
367   _Success_(return == 0)
368   _CRTIMP
369   errno_t
370   __cdecl
371   _wctime64_s(
372     _Out_writes_(_SizeInWords) _Post_readable_size_(26) wchar_t *_Buf,
373     _In_ size_t _SizeInWords,
374     _In_ const __time64_t *_Time);
375 
376 #endif /* _INTEGRAL_MAX_BITS >= 64 */
377 
378 #if !defined (RC_INVOKED) && !defined (_INC_WTIME_INL)
379 #define _INC_WTIME_INL
380 #ifdef _USE_32BIT_TIME_T
381 /* Do it like this to be compatible to msvcrt.dll on 32 bit windows XP and before */
382 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime32(_Time); }
383 #else
384 __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); }
385 #endif
386 #endif
387 
388 #endif /* !_WTIME_DEFINED */
389 
390  _CRTIMP double __cdecl difftime(time_t _Time1,time_t _Time2);
391  _CRTIMP char *__cdecl ctime(const time_t *_Time);
392  _CRTIMP struct tm *__cdecl gmtime(const time_t *_Time);
393  _CRTIMP struct tm *__cdecl localtime(const time_t *_Time);
394  _CRTIMP struct tm *__cdecl localtime_r(const time_t *_Time,struct tm *);
395 
396  _CRTIMP time_t __cdecl mktime(struct tm *_Tm);
397  _CRTIMP time_t __cdecl _mkgmtime(struct tm *_Tm);
398  _CRTIMP time_t __cdecl time(time_t *_Time);
399 
400 #if !defined(RC_INVOKED)  && !defined(_NO_INLINING)  && !defined(_CRTBLD)
401 #ifdef _USE_32BIT_TIME_T
402 #if 0
403 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime32(_Time1,_Time2); }
404 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime32(_Time); }
405 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime32(_Time); }
406 __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime32(_Time); }
407 __CRT_INLINE errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime32_s(_Tm,_Time); }
408 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime32(_Tm); }
409 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); }
410 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time32(_Time); }
411 #endif
412 #else
413 __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); }
414 __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime64(_Time); }
415 __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime64(_Time); }
416 __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime64(_Time); }
417 __CRT_INLINE errno_t __cdecl localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime64_s(_Tm,_Time); }
418 __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime64(_Tm); }
419 __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime64(_Tm); }
420 __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time64(_Time); }
421 #endif
422 #endif
423 
424 #if !defined(NO_OLDNAMES) || defined(_POSIX)
425 #define CLK_TCK CLOCKS_PER_SEC
426 
427   _CRTIMP extern int daylight;
428   _CRTIMP extern long timezone;
429   _CRTIMP extern char *tzname[2];
430   _CRTIMP void __cdecl tzset(void);
431 #endif
432 
433 #ifdef __cplusplus
434 }
435 #endif
436 
437 #pragma pack(pop)
438 
439 #endif /* End _TIME_H_ */
440