ReactOS 0.4.16-dev-732-g2d1144a
time.h
Go to the documentation of this file.
1//
2// time.h
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The C Standard Library <time.h> header.
7//
8#pragma once
9#ifndef _INC_TIME // include guard for 3rd party interop
10#define _INC_TIME
11
12#include <corecrt.h>
13#include <corecrt_wtime.h>
14
15#pragma warning(push)
16#pragma warning(disable: _UCRT_DISABLED_WARNINGS)
18
20
21#ifndef _CRT_USE_CONFORMING_ANNEX_K_TIME
22#define _CRT_USE_CONFORMING_ANNEX_K_TIME 0
23#endif
24
25//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26//
27// Types
28//
29//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30typedef long clock_t;
31
33{
35 long tv_nsec;
36};
37
39{
41 long tv_nsec;
42};
43
44#ifndef _CRT_NO_TIME_T
45 struct timespec
46 {
47 time_t tv_sec; // Seconds - >= 0
48 long tv_nsec; // Nanoseconds - [0, 999999999]
49 };
50#endif
51
52
53
54// The number of clock ticks per second
55#define CLOCKS_PER_SEC ((clock_t)1000)
56
57#define TIME_UTC 1
58
59
60
61//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62//
63// Time Zone and Daylight Savings Time Data and Accessors
64//
65//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66// Nonzero if Daylight Savings Time is used
68_ACRTIMP int* __cdecl __daylight(void);
69
70#define _daylight (*__daylight())
71
72// Offset for Daylight Savings Time
74_ACRTIMP long* __cdecl __dstbias(void);
75
76#define _dstbias (*__dstbias())
77
78// Difference in seconds between GMT and local time
80_ACRTIMP long* __cdecl __timezone(void);
81
82#define _timezone (*__timezone())
83
84// Standard and Daylight Savings Time time zone names
86_ACRTIMP char** __cdecl __tzname(void);
87
88#define _tzname (__tzname())
89
90 _Success_(_Daylight != 0)
92 _Out_ int* _Daylight
93 );
94
95_Success_(_DaylightSavingsBias != 0)
97 _Out_ long* _DaylightSavingsBias
98 );
99
100 _Success_(_TimeZone != 0)
102 _Out_ long* _TimeZone
103 );
104
105_Success_(return == 0)
107 _Out_ size_t* _ReturnValue,
111 );
112
113
114
115//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116//
117// AppCRT Time Functions
118//
119//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
125 );
126
127#if __STDC_WANT_SECURE_LIB__
128 _Success_(return == 0)
132 _In_range_(>=,26) size_t _SizeInBytes,
134 );
135#endif
136
140 _In_ struct tm const*, _Time
141 )
142
145
147_Success_(return != 0)
151 );
152
156 _In_range_(>=,26) size_t _SizeInBytes,
158 );
159
164 )
165
167_Success_(return != 0)
171 );
172
176 _In_range_(>=,26) size_t _SizeInBytes,
178 );
179
184 )
185
188 _In_ __time32_t _Time1,
190 );
191
194 _In_ __time64_t _Time1,
196 );
197
198_Success_(return != 0)
202 );
203
208 );
209
210_Success_(return != 0)
214 );
215
220 );
221
222_Success_(return != 0)
226 );
227
232 );
233
234_Success_(return != 0)
238 );
239
244 );
245
249 );
250
254 );
255
259 );
260
264 );
265
270 _In_ size_t _SizeInBytes,
273 );
274
275_Success_(return > 0)
283 );
284
288 _In_ size_t _SizeInBytes
289 );
290
294 )
295
299 )
300
304 _In_ size_t _SizeInBytes
305 );
306
310 )
311
314 _Out_writes_z_(9), char, _Buffer
315 )
316
319 );
320
323 );
324
325_Success_(return != 0)
330 );
331
332_Success_(return != 0)
336 _In_ int _Base
337 );
338
339
340
341//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
342//
343// DesktopCRT Time Functions
344//
345//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
346#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
347
348 _ACRTIMP void __cdecl _tzset(void);
349
350 // The Win32 API GetLocalTime and SetLocalTime should be used instead.
353 _Out_ struct tm* _Tm
354 );
355
358 _In_ struct tm* _Tm,
359 _In_ unsigned _Milliseconds
360 );
361
362#endif
363
364
365
366//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367//
368// Inline Function Definitions
369//
370//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371#if !defined RC_INVOKED && !defined __midl && !defined _INC_TIME_INL && !defined _CRT_NO_TIME_T
372
373 #ifdef _USE_32BIT_TIME_T
374
376 static __inline char* __CRTDECL ctime(
377 _In_ time_t const* const _Time
378 )
379 {
380 return _ctime32(_Time);
381 }
382
384 static __inline double __CRTDECL difftime(
385 _In_ time_t const _Time1,
386 _In_ time_t const _Time2
387 )
388 {
389 return _difftime32(_Time1, _Time2);
390 }
391
393 static __inline struct tm* __CRTDECL gmtime(
394 _In_ time_t const* const _Time
395 )
396 {
397 return _gmtime32(_Time);
398 }
399
401 static __inline struct tm* __CRTDECL localtime(
402 _In_ time_t const* const _Time
403 )
404 {
405 return _localtime32(_Time);
406 }
407
410 _Inout_ struct tm* const _Tm
411 )
412 {
413 return _mkgmtime32(_Tm);
414 }
415
418 _Inout_ struct tm* const _Tm
419 )
420 {
421 return _mktime32(_Tm);
422 }
423
425 _Out_opt_ time_t* const _Time
426 )
427 {
428 return _time32(_Time);
429 }
430
433 _Out_ struct timespec* const _Ts,
434 _In_ int const _Base
435 )
436 {
437 return _timespec32_get((struct _timespec32*)_Ts, _Base);
438 }
439
440 #if __STDC_WANT_SECURE_LIB__
442 static __inline errno_t __CRTDECL ctime_s(
444 _In_range_(>=,26) size_t const _SizeInBytes,
445 _In_ time_t const* const _Time
446 )
447 {
449 }
450
451 #if _CRT_USE_CONFORMING_ANNEX_K_TIME
453 static __inline struct tm* __CRTDECL gmtime_s(
454 _In_ time_t const* const _Time,
455 _Out_ struct tm* const _Tm
456 )
457 {
458 if (_gmtime32_s(_Tm, _Time) == 0)
459 {
460 return _Tm;
461 }
462 return NULL;
463 }
464
466 static __inline struct tm* __CRTDECL localtime_s(
467 _In_ time_t const* const _Time,
468 _Out_ struct tm* const _Tm
469 )
470 {
471 if (_localtime32_s(_Tm, _Time) == 0)
472 {
473 return _Tm;
474 }
475 return NULL;
476 }
477 #else // _CRT_USE_CONFORMING_ANNEX_K_TIME
479 static __inline errno_t __CRTDECL gmtime_s(
480 _Out_ struct tm* const _Tm,
481 _In_ time_t const* const _Time
482 )
483 {
484 return _gmtime32_s(_Tm, _Time);
485 }
486
489 _Out_ struct tm* const _Tm,
490 _In_ time_t const* const _Time
491 )
492 {
493 return _localtime32_s(_Tm, _Time);
494 }
495 #endif // _CRT_USE_CONFORMING_ANNEX_K_TIME
496 #endif
497
498 #else // ^^^ _USE_32BIT_TIME_T ^^^ // vvv !_USE_32BIT_TIME_T vvv
499
501 static __inline char* __CRTDECL ctime(
502 _In_ time_t const* const _Time
503 )
504 {
505 return _ctime64(_Time);
506 }
507
510 _In_ time_t const _Time1,
511 _In_ time_t const _Time2
512 )
513 {
514 return _difftime64(_Time1, _Time2);
515 }
516
518 static __inline struct tm* __CRTDECL gmtime(
519 _In_ time_t const* const _Time)
520 {
521 return _gmtime64(_Time);
522 }
523
527 )
528 {
529 return _localtime64(_Time);
530 }
531
534 _Inout_ struct tm* const _Tm
535 )
536 {
537 return _mkgmtime64(_Tm);
538 }
539
542 _Inout_ struct tm* const _Tm
543 )
544 {
545 return _mktime64(_Tm);
546 }
547
549 _Out_opt_ time_t* const _Time
550 )
551 {
552 return _time64(_Time);
553 }
554
557 _Out_ struct timespec* const _Ts,
558 _In_ int const _Base
559 )
560 {
561 return _timespec64_get((struct _timespec64*)_Ts, _Base);
562 }
563
564 #if __STDC_WANT_SECURE_LIB__
566 static __inline errno_t __CRTDECL ctime_s(
568 _In_range_(>=,26) size_t const _SizeInBytes,
569 _In_ time_t const* const _Time
570 )
571 {
573 }
574
575 #if _CRT_USE_CONFORMING_ANNEX_K_TIME
577 static __inline struct tm* __CRTDECL gmtime_s(
578 _In_ time_t const* const _Time,
579 _Out_ struct tm* const _Tm
580 )
581 {
582 if (_gmtime64_s(_Tm, _Time) == 0)
583 {
584 return _Tm;
585 }
586 return NULL;
587 }
588
590 static __inline struct tm* __CRTDECL localtime_s(
591 _In_ time_t const* const _Time,
592 _Out_ struct tm* const _Tm
593 )
594 {
595 if (_localtime64_s(_Tm, _Time) == 0)
596 {
597 return _Tm;
598 }
599 return NULL;
600 }
601 #else // _CRT_USE_CONFORMING_ANNEX_K_TIME
603 static __inline errno_t __CRTDECL gmtime_s(
604 _Out_ struct tm* const _Tm,
605 _In_ time_t const* const _Time
606 )
607 {
608 return _gmtime64_s(_Tm, _Time);
609 }
610
613 _Out_ struct tm* const _Tm,
614 _In_ time_t const* const _Time
615 )
616 {
617 return _localtime64_s(_Tm, _Time);
618 }
619 #endif // _CRT_USE_CONFORMING_ANNEX_K_TIME
620 #endif
621
622 #endif // !_USE_32BIT_TIME_T
623
624#endif
625
626
627
628//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
629//
630// Non-ANSI Names for Compatibility
631//
632//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
633#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES
634
635 #define CLK_TCK CLOCKS_PER_SEC
636
637 #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
639 #endif
640
641#endif // _CRT_INTERNAL_NONSTDC_NAMES
642
643
644
647#pragma warning(pop) // _UCRT_DISABLED_WARNINGS
648#endif // _INC_TIME
#define __inline
Definition: _wctype.cpp:15
#define __cdecl
Definition: accygwin.h:79
return
Definition: dirsup.c:529
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1)
Definition: corecrt.h:177
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(_ReturnType, _FuncName, _DstType, _Dst)
Definition: corecrt.h:176
char *__cdecl _ctime64(__time64_t const *const time_t_value)
Definition: ctime.cpp:116
#define NULL
Definition: types.h:112
BOOL WINAPI SetLocalTime(IN CONST SYSTEMTIME *lpSystemTime)
Definition: time.c:356
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
__kernel_time_t time_t
Definition: linux.h:252
__kernel_clock_t clock_t
Definition: linux.h:257
struct tm * _gmtime64(const __time64_t *ptime)
Definition: gmtime.c:104
_In_ _Pre_notnull_ _Buffer
Definition: stdlib.h:644
tm *__cdecl _localtime64(__time64_t const *const ptime)
Definition: localtime.cpp:208
__u16 ctime
Definition: mkdosfs.c:4
__u16 time
Definition: mkdosfs.c:8
#define _Deref_ret_z_
Definition: ms_sal.h:1206
#define _Out_writes_z_(s)
Definition: no_sal2.h:180
#define _Out_opt_
Definition: no_sal2.h:214
#define _Post_readable_size_(s)
Definition: no_sal2.h:536
#define _Inout_
Definition: no_sal2.h:162
#define _Success_(c)
Definition: no_sal2.h:84
#define _In_z_
Definition: no_sal2.h:164
#define _Check_return_
Definition: no_sal2.h:60
#define _Ret_writes_z_(s)
Definition: no_sal2.h:312
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define _In_range_(l, h)
Definition: no_sal2.h:368
#define _Printf_format_string_
Definition: no_sal2.h:356
#define _Ret_z_
Definition: no_sal2.h:306
#define _When_(c, a)
Definition: no_sal2.h:38
_Check_return_wat_ _CRTIMP errno_t __cdecl _strdate_s(_Out_writes_(_SizeInBytes) _Post_readable_size_(9) char *_Buf, _In_range_(>=, 9) size_t _SizeInBytes)
_CRTIMP struct tm *__cdecl _localtime32(_In_ const __time32_t *_Time)
_CRTIMP errno_t __cdecl _get_tzname(_Out_ size_t *_ReturnValue, _Out_writes_z_(_SizeInBytes) char *_Buffer, _In_ size_t _SizeInBytes, _In_ int _Index)
_CRTIMP __time32_t __cdecl _mktime32(_Inout_ struct tm *_Tm)
_CRTIMP double __cdecl difftime(time_t _Time1, time_t _Time2)
Definition: time.h:413
_CRTIMP errno_t __cdecl _get_daylight(_Out_ int *_Daylight)
_Check_return_ _CRTIMP char *__cdecl asctime(_In_ const struct tm *_Tm)
_CRTIMP struct tm *__cdecl gmtime(const time_t *_Time)
Definition: time.h:415
_In_ size_t _In_ const __time32_t * _Time
Definition: time.h:192
_In_ size_t _SizeInBytes
Definition: time.h:146
_In_ size_t _In_z_ _Printf_format_string_ const char * _Format
Definition: time.h:147
_CRTIMP void __cdecl tzset(void)
long clock_t
Definition: time.h:49
__CRT_INLINE errno_t __cdecl localtime_s(struct tm *_Tm, const time_t *_Time)
Definition: time.h:417
_CRTIMP time_t __cdecl mktime(struct tm *_Tm)
Definition: time.h:418
_Check_return_wat_ _CRTIMP errno_t __cdecl _strtime_s(_Out_writes_(_SizeInBytes) _Post_readable_size_(9) char *_Buf, _In_range_(>=, 9) size_t _SizeInBytes)
unsigned __cdecl _setsystime(_In_ struct tm *_Tm, unsigned _MilliSec)
_Check_return_ _CRTIMP clock_t __cdecl clock(void)
Definition: clock.c:23
_Check_return_ _CRTIMP struct tm *__cdecl _gmtime32(_In_ const __time32_t *_Time)
_Check_return_wat_ _CRTIMP errno_t __cdecl asctime_s(_Out_writes_(_SizeInBytes) _Post_readable_size_(26) char *_Buf, _In_range_(>=, 26) size_t _SizeInBytes, _In_ const struct tm *_Tm)
_CRTIMP time_t __cdecl _mkgmtime(struct tm *_Tm)
Definition: time.h:419
_CRTIMP double __cdecl _difftime32(_In_ __time32_t _Time1, _In_ __time32_t _Time2)
_CRTIMP __time32_t __cdecl _time32(_Out_opt_ __time32_t *_Time)
_CRTIMP __time32_t __cdecl _mkgmtime32(_Inout_ struct tm *_Tm)
_CRTIMP errno_t __cdecl _get_dstbias(_Out_ long *_Daylight_savings_bias)
_CRTIMP char *__cdecl _ctime32(_In_ const __time32_t *_Time)
_In_ size_t _In_z_ _Printf_format_string_ const char _In_ const struct tm _In_opt_ _locale_t _Locale
Definition: time.h:159
_CRTIMP void __cdecl _tzset(void)
Definition: timezone.c:92
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
_Check_return_wat_ _CRTIMP errno_t __cdecl _gmtime32_s(_In_ struct tm *_Tm, _In_ const __time32_t *_Time)
_CRTIMP errno_t __cdecl _get_timezone(_Out_ long *_Timezone)
_In_ size_t _In_z_ _Printf_format_string_ const char _In_ const struct tm * _Tm
Definition: time.h:148
_CRTIMP errno_t __cdecl _localtime32_s(_Out_ struct tm *_Tm, _In_ const __time32_t *_Time)
long __time32_t
Definition: time.h:24
_Check_return_wat_ _ACRTIMP errno_t __cdecl _ctime32_s(_Out_writes_(_SizeInBytes) _Post_readable_size_(26) char *_Buffer, _In_range_(>=, 26) size_t _SizeInBytes, _In_ __time32_t const *_Time)
_In_ size_t _In_ int _Index
Definition: time.h:111
_strdate
Definition: time.h:297
_Check_return_ _ACRTIMP __time64_t __cdecl _mkgmtime64(_Inout_ struct tm *_Tm)
_In_ int _Base
Definition: time.h:330
static _Check_return_ __inline int __CRTDECL timespec_get(_Out_ struct timespec *const _Ts, _In_ int const _Base)
Definition: time.h:556
_Check_return_opt_ _ACRTIMP __time64_t __cdecl _mktime64(_Inout_ struct tm *_Tm)
_Check_return_ _ACRTIMP double __cdecl _difftime64(_In_ __time64_t _Time1, _In_ __time64_t _Time2)
_Check_return_wat_ _ACRTIMP errno_t __cdecl _localtime64_s(_Out_ struct tm *_Tm, _In_ __time64_t const *_Time)
_Check_return_wat_ _ACRTIMP errno_t __cdecl _gmtime64_s(_Out_ struct tm *_Tm, _In_ __time64_t const *_Time)
__RETURN_POLICY_DST
Definition: time.h:297
_ACRTIMP
Definition: time.h:297
_strtime
Definition: time.h:313
_In_ size_t _MaxSize
Definition: time.h:279
_ACRTIMP __time64_t __cdecl _time64(_Out_opt_ __time64_t *_Time)
_In_ __time32_t _Time2
Definition: time.h:190
_Check_return_wat_ _ACRTIMP errno_t __cdecl _ctime64_s(_Out_writes_z_(_SizeInBytes) _Post_readable_size_(26) char *_Buffer, _In_range_(>=, 26) size_t _SizeInBytes, _In_ __time64_t const *_Time)
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Definition: strftime.c:294
size_t __cdecl _strftime_l(char *const string, size_t const max_size, char const *const format, tm const *const timeptr, _locale_t const locale)
Definition: strftime.cpp:181
long tv_nsec
Definition: time.h:35
__time32_t tv_sec
Definition: time.h:34
__time64_t tv_sec
Definition: time.h:40
long tv_nsec
Definition: time.h:41
Definition: time.h:46
long tv_nsec
Definition: time.h:48
time_t tv_sec
Definition: time.h:47
Definition: time.h:68
unsigned int _getsystime(struct tm *tp)
Definition: systime.c:18
int __cdecl _timespec64_get(_timespec64 *const ts, int const base)
Definition: time.cpp:53
int __cdecl _timespec32_get(_timespec32 *const ts, int const base)
Definition: time.cpp:48
int *__cdecl __daylight()
Definition: timeset.cpp:165
long *__cdecl __dstbias()
Definition: timeset.cpp:170
char **__cdecl __tzname()
Definition: timeset.cpp:180
long *__cdecl __timezone()
Definition: timeset.cpp:175
#define _CRT_OBSOLETE(_NewItem)
Definition: corecrt.h:549
#define _Check_return_opt_
Definition: corecrt.h:224
#define _DCRTIMP
Definition: corecrt.h:154
#define _CRT_NONSTDC_DEPRECATE(_NewName)
Definition: corecrt.h:439
__int64 __time64_t
Definition: corecrt.h:619
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SalAttributeDst, _DstType, _Dst)
Definition: corecrt.h:842
#define _UCRT_DISABLE_CLANG_WARNINGS
Definition: corecrt.h:109
#define _UCRT_RESTORE_CLANG_WARNINGS
Definition: corecrt.h:117
#define _Check_return_wat_
Definition: corecrt.h:230
#define _CRT_INSECURE_DEPRECATE_GLOBALS(replacement)
Definition: corecrt.h:530
int errno_t
Definition: corecrt.h:615
#define _CRT_END_C_HEADER
Definition: vcruntime.h:42
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:40
#define _CRT_INSECURE_DEPRECATE(_Replacement)
Definition: vcruntime.h:99
#define __CRTDECL
Definition: yvals.h:17
#define const
Definition: zconf.h:233