summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2003/man0p/time.h.0p
blob: ce643683ea7e18e82a3a7e5948e9dcd573ffaa39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "<time.h>" 0P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <time.h> 
.SH NAME
time.h \- time types
.SH SYNOPSIS
.LP
\fB#include <time.h>\fP
.SH DESCRIPTION
.LP
Some of the functionality described on this reference page extends
the ISO\ C standard. Applications shall define
the appropriate feature test macro (see the System Interfaces volume
of IEEE\ Std\ 1003.1-2001, Section 2.2, The Compilation Environment)
to enable the visibility of these symbols in this
header. 
.LP
The \fI<time.h>\fP header shall declare the structure \fBtm\fP, which
shall include at least the following members:
.sp
.RS
.nf

\fBint    tm_sec  \fP Seconds [0,60]. \fB
int    tm_min  \fP Minutes [0,59]. \fB
int    tm_hour \fP Hour [0,23]. \fB
int    tm_mday \fP Day of month [1,31]. \fB
int    tm_mon  \fP Month of year [0,11]. \fB
int    tm_year \fP Years since 1900. \fB
int    tm_wday \fP Day of week [0,6] (Sunday =0). \fB
int    tm_yday \fP Day of year [0,365]. \fB
int    tm_isdst\fP Daylight Savings flag. \fB
\fP
.fi
.RE
.LP
The value of \fItm_isdst\fP shall be positive if Daylight Savings
Time is in effect, 0 if Daylight Savings Time is not in
effect, and negative if the information is not available.
.LP
The \fI<time.h>\fP header shall define the following symbolic names:
.TP 7
NULL
Null pointer constant.
.TP 7
CLOCKS_PER_SEC
A number used to convert the value returned by the \fIclock\fP() function
into
seconds.
.TP 7
CLOCK_PROCESS_CPUTIME_ID
.sp
The identifier of the CPU-time clock associated with the process making
a \fIclock\fP() or
\fItimer*\fP() function call. 
.TP 7
CLOCK_THREAD_CPUTIME_ID
.sp
The identifier of the CPU-time clock associated with the thread making
a \fIclock\fP() or \fItimer*\fP() function call. 
.sp
.LP
The \fI<time.h>\fP header shall declare the structure \fBtimespec\fP,
which has at least the following members:
.sp
.RS
.nf

\fBtime_t  tv_sec   \fP Seconds. \fB
long    tv_nsec  \fP Nanoseconds. \fB
\fP
.fi
.RE
.LP
The \fI<time.h>\fP header shall also declare the \fBitimerspec\fP
structure, which has at least the following
members:
.sp
.RS
.nf

\fBstruct timespec  it_interval \fP Timer period. \fB
struct timespec  it_value    \fP Timer expiration. \fB
\fP
.fi
.RE
.LP
The following manifest constants shall be defined:
.TP 7
CLOCK_REALTIME
The identifier of the system-wide realtime clock.
.TP 7
TIMER_ABSTIME
Flag indicating time is absolute. For functions taking timer objects,
this refers to the clock associated with the timer. 
.TP 7
CLOCK_MONOTONIC
.sp
The identifier for the system-wide monotonic clock, which is defined
as a clock whose value cannot be set via \fIclock_settime\fP() and
which cannot have backward clock jumps. The maximum possible clock
jump shall be implementation-defined. 
.sp
.LP
The \fBclock_t\fP, \fBsize_t\fP, \fBtime_t\fP,   \fBclockid_t\fP,
and \fBtimer_t\fP  types shall be defined as described in \fI<sys/types.h>\fP
\&.
.LP
Although the value of CLOCKS_PER_SEC is required to be 1 million on
all XSI-conformant systems, it may be variable on other
systems, and it should not be assumed that CLOCKS_PER_SEC is a compile-time
constant. 
.LP
The \fI<time.h>\fP header shall provide a declaration for \fIgetdate_err\fP.
.LP
The following shall be declared as functions and may also be defined
as macros. Function prototypes shall be provided.
.sp
.RS
.nf

\fBchar      *asctime(const struct tm *);

char      *asctime_r(const struct tm *restrict, char *restrict);

clock_t    clock(void);

int        clock_getcpuclockid(pid_t, clockid_t *);


int        clock_getres(clockid_t, struct timespec *);
int        clock_gettime(clockid_t, struct timespec *);


int        clock_nanosleep(clockid_t, int, const struct timespec *,
               struct timespec *);


int        clock_settime(clockid_t, const struct timespec *);

char      *ctime(const time_t *);

char      *ctime_r(const time_t *, char *);

double     difftime(time_t, time_t);

struct tm *getdate(const char *);

struct tm *gmtime(const time_t *);

struct tm *gmtime_r(const time_t *restrict, struct tm *restrict);

struct tm *localtime(const time_t *);

struct tm *localtime_r(const time_t *restrict, struct tm *restrict);

time_t     mktime(struct tm *);

int        nanosleep(const struct timespec *, struct timespec *);

size_t     strftime(char *restrict, size_t, const char *restrict,
           const struct tm *restrict);

char      *strptime(const char *restrict, const char *restrict,
               struct tm *restrict);

time_t     time(time_t *);

int        timer_create(clockid_t, struct sigevent *restrict,
               timer_t *restrict);
int        timer_delete(timer_t);
int        timer_gettime(timer_t, struct itimerspec *);
int        timer_getoverrun(timer_t);
int        timer_settime(timer_t, int, const struct itimerspec *restrict,
               struct itimerspec *restrict);


void       tzset(void);

\fP
.fi
.RE
.sp
.LP
The following shall be declared as variables:
.sp
.RS
.nf

\fB
extern int    daylight;
extern long   timezone;


extern char  *tzname[];

\fP
.fi
.RE
.LP
Inclusion of the \fI<time.h>\fP header may make visible all symbols
from the \fI<signal.h>\fP header. 
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
The range [0,60] for \fItm_sec\fP allows for the occasional leap second.
.LP
\fItm_year\fP is a signed value; therefore, years before 1900 may
be represented.
.LP
To obtain the number of clock ticks per second returned by the \fItimes\fP()
function,
applications should call \fIsysconf\fP(_SC_CLK_TCK).
.SH RATIONALE
.LP
The range [0,60] seconds allows for positive or negative leap seconds.
The formal definition of UTC does not permit double leap
seconds, so all mention of double leap seconds has been removed, and
the range shortened from the former [0,61] seconds seen in
previous versions of POSIX.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fI<signal.h>\fP, \fI<sys/types.h>\fP, the System
Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIasctime\fP(), \fIclock\fP(),
\fIclock_getcpuclockid\fP(), \fIclock_getres\fP(), \fIclock_nanosleep\fP(),
\fIctime\fP(), \fIdifftime\fP(), \fIgetdate\fP(), \fIgmtime\fP(),
\fIlocaltime\fP(), \fImktime\fP(), \fInanosleep\fP(), \fIstrftime\fP(),
\fIstrptime\fP(), \fIsysconf\fP(), \fItime\fP(), \fItimer_create\fP(),
\fItimer_delete\fP(), \fItimer_getoverrun\fP(), \fItzname\fP, \fItzset\fP(),
\fIutime\fP()
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .