branch update for HEAD-2003021201
[reactos.git] / include / msvcrt / time.h
1 /* 
2  * time.h
3  *
4  * Date and time functions and types.
5  *
6  * This file is part of the Mingw32 package.
7  *
8  * Contributors:
9  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
10  *
11  *  THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  *  This source code is offered for use in the public domain. You may
14  *  use, modify or distribute it freely.
15  *
16  *  This code is distributed in the hope that it will be useful but
17  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  *  DISCLAIMED. This includes but is not limited to warranties of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * $Revision$
22  * $Author$
23  * $Date$
24  *
25  */
26 /* Appropriated for Reactos Crtdll by Ariadne */
27 #ifndef _TIME_H_
28 #define _TIME_H_
29
30 #define __need_wchar_t
31 #define __need_size_t
32 #include <msvcrt/stddef.h>
33
34
35 /*
36  * Number of clock ticks per second. A clock tick is the unit by which
37  * processor time is measured and is returned by 'clock'.
38  */
39 #define CLOCKS_PER_SEC  1000.0
40 #define CLK_TICK    CLOCKS_PER_SEC
41
42
43 /*
44  * Need a definition of time_t.
45  */
46 #include <msvcrt/sys/types.h>
47
48 /*
49  * A type for storing the current time and date. This is the number of
50  * seconds since midnight Jan 1, 1970.
51  * NOTE: Normally this is defined by the above include of sys/types.h
52  */
53 #ifndef _TIME_T_
54 typedef long    time_t;
55 #define _TIME_T_
56 #endif
57
58 /*
59  * A type for measuring processor time (in clock ticks).
60  */
61 #ifndef _CLOCK_T_
62 typedef long    clock_t;
63 #define _CLOCK_T_
64 #endif
65
66 /*
67  * A structure for storing all kinds of useful information about the
68  * current (or another) time.
69  */
70 struct tm
71 {
72     int tm_sec;     /* Seconds: 0-59 (K&R says 0-61?) */
73     int tm_min;     /* Minutes: 0-59 */
74     int tm_hour;    /* Hours since midnight: 0-23 */
75     int tm_mday;    /* Day of the month: 1-31 */
76     int tm_mon;     /* Months *since* january: 0-11 */
77     int tm_year;    /* Years since 1900 */
78     int tm_wday;    /* Days since Sunday (0-6) */
79     int tm_yday;    /* Days since Jan. 1: 0-365 */
80     int tm_isdst;   /* +1 Daylight Savings Time, 0 No DST,
81                  * -1 don't know */
82     char *tm_zone;
83     int tm_gmtoff;
84 };
85
86 #ifdef  __cplusplus
87 extern "C" {
88 #endif
89
90 clock_t clock(void);
91 time_t time(time_t*);
92 double difftime(time_t, time_t);
93 time_t mktime(struct tm*);
94
95 /*
96  * These functions write to and return pointers to static buffers that may
97  * be overwritten by other function calls. Yikes!
98  *
99  * NOTE: localtime, and perhaps the others of the four functions grouped
100  * below may return NULL if their argument is not 'acceptable'. Also note
101  * that calling asctime with a NULL pointer will produce an Invalid Page
102  * Fault and crap out your program. Guess how I know. Hint: stat called on
103  * a directory gives 'invalid' times in st_atime etc...
104  */
105 char* asctime(const struct tm*);
106 char* ctime(const time_t*);
107 struct tm* gmtime(const time_t*);
108 struct tm* localtime(const time_t*);
109
110 size_t strftime(char*, size_t, const char*, const struct tm*);
111 size_t wcsftime(wchar_t*, size_t, const wchar_t*, const struct tm*);
112
113 wchar_t* _wasctime(const struct tm *timeptr);
114 wchar_t* _wctime(const time_t * const timep);
115 char* _strdate(const char *datestr);
116 wchar_t* _wstrdate(const wchar_t *datestr);
117 char* _strtime(char* buf);
118 wchar_t* _wstrtime(wchar_t* buf);
119
120 #ifdef  __cplusplus
121 }
122 #endif
123
124 #endif  /* Not _TIME_H_ */
125