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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
|
'\" et
.TH time.h "0P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
time.h
\(em time types
.SH SYNOPSIS
.LP
.nf
#include <time.h>
.fi
.SH DESCRIPTION
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 POSIX.1\(hy2008,
.IR "Section 2.2" ", " "The Compilation Environment")
to enable the visibility of these symbols in this header.
.P
The
.IR <time.h>
header shall define the
.BR clock_t ,
.BR size_t ,
.BR time_t ,
types as described in
.IR <sys/types.h> .
.P
The
.IR <time.h>
header shall define the
.BR clockid_t
and
.BR timer_t
types as described in
.IR <sys/types.h> .
.P
The
.IR <time.h>
header shall define the
.BR locale_t
type as described in
.IR <locale.h> .
.P
The
.IR <time.h>
header shall define the
.BR pid_t
type as described in
.IR <sys/types.h> .
.P
The tag
.BR sigevent
shall be declared as naming an incomplete structure type, the contents
of which are described in the
.IR <signal.h>
header.
.P
The
.IR <time.h>
header shall declare the
.BR tm
structure, which shall include at least the following members:
.sp
.RS 4
.nf
\fB
int tm_sec \fRSeconds [0,60].\fR
int tm_min \fRMinutes [0,59].\fR
int tm_hour \fRHour [0,23].\fR
int tm_mday \fRDay of month [1,31].\fR
int tm_mon \fRMonth of year [0,11].\fR
int tm_year \fRYears since 1900.\fR
int tm_wday \fRDay of week [0,6] (Sunday =0).\fR
int tm_yday \fRDay of year [0,365].\fR
int tm_isdst \fRDaylight Savings flag.\fR
.fi \fR
.P
.RE
.P
The value of
.IR tm_isdst
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.
.P
The
.IR <time.h>
header shall declare the
.BR timespec
structure, which shall include at least the following members:
.sp
.RS 4
.nf
\fB
time_t tv_sec \fRSeconds.\fR
long tv_nsec \fRNanoseconds.\fR
.fi \fR
.P
.RE
.P
The
.IR <time.h>
header shall also declare the
.BR itimerspec
structure, which shall include at least the following members:
.sp
.RS 4
.nf
\fB
struct timespec it_interval \fRTimer period.\fR
struct timespec it_value \fRTimer expiration.\fR
.fi \fR
.P
.RE
.P
The
.IR <time.h>
header shall define the following macros:
.IP NULL 14
As described in
.IR <stddef.h> .
.IP CLOCKS_PER_SEC 14
A number used to convert the value returned by the
\fIclock\fR()
function into seconds. The value shall be an expression with type
.BR clock_t .
The value of CLOCKS_PER_SEC shall be 1 million
on XSI-conformant systems. However, it may be variable on other systems,
and it should not be assumed that CLOCKS_PER_SEC is a compile-time
constant.
.P
The
.IR <time.h>
header shall define the following symbolic constants. The values shall
have a type that is assignment-compatible with
.BR clockid_t .
.IP CLOCK_MONOTONIC 14
.br
The identifier for the system-wide monotonic clock, which is defined as
a clock measuring real time, whose value cannot be set via
\fIclock_settime\fR()
and which cannot have negative clock jumps. The maximum possible clock
jump shall be implementation-defined.
.IP CLOCK_PROCESS_CPUTIME_ID 14
.br
The identifier of the CPU-time clock associated with the process
making a
\fIclock\fR()
or
.IR timer* (\|)
function call.
.IP CLOCK_REALTIME 14
The identifier of the system-wide clock measuring real time.
.IP CLOCK_THREAD_CPUTIME_ID 14
.br
The identifier of the CPU-time clock associated with the thread making a
\fIclock\fR()
or
.IR timer* (\|)
function call.
.P
The
.IR <time.h>
header shall define the following symbolic constant:
.IP TIMER_ABSTIME 14
Flag indicating time is absolute. For functions taking timer objects,
this refers to the clock associated with the timer.
.P
The
.IR <time.h>
header shall provide a declaration or definition for
.IR getdate_err .
The
.IR getdate_err
symbol shall expand to an expression of type
.BR int .
It is unspecified whether
.IR getdate_err
is a macro or an identifier declared with external linkage, and whether or
not it is a modifiable lvalue. If a macro definition is suppressed in
order to access an actual object, or a program defines an identifier
with the name
.IR getdate_err ,
the behavior is undefined.
.P
The following shall be declared as functions and may also be defined
as macros. Function prototypes shall be provided.
.sp
.RS 4
.nf
\fB
char *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);
size_t strftime_l(char *restrict, size_t, const char *restrict,
const struct tm *restrict, locale_t);
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_getoverrun(timer_t);
int timer_gettime(timer_t, struct itimerspec *);
int timer_settime(timer_t, int, const struct itimerspec *restrict,
struct itimerspec *restrict);
void tzset(void);
.fi \fR
.P
.RE
.br
.P
The
.IR <time.h>
header shall declare the following as variables:
.sp
.RS 4
.nf
\fB
extern int daylight;
extern long timezone;
extern char *tzname[];
.fi \fR
.P
.RE
.P
Inclusion of the
.IR <time.h>
header may make visible all symbols from the
.IR <signal.h>
header.
.LP
.IR "The following sections are informative."
.SH "APPLICATION USAGE"
The range [0,60] for
.IR tm_sec
allows for the occasional leap second.
.P
.IR tm_year
is a signed value; therefore, years before 1900 may be represented.
.P
To obtain the number of clock ticks per second returned by the
\fItimes\fR()
function, applications should call
.IR sysconf (_SC_CLK_TCK).
.SH RATIONALE
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 earlier versions of
this standard.
.SH "FUTURE DIRECTIONS"
None.
.SH "SEE ALSO"
.IR "\fB<locale.h>\fP",
.IR "\fB<signal.h>\fP",
.IR "\fB<stddef.h>\fP",
.IR "\fB<sys_types.h>\fP"
.P
.ad l
The System Interfaces volume of POSIX.1\(hy2008,
.IR "Section 2.2" ", " "The Compilation Environment",
.IR "\fIasctime\fR\^(\|)",
.IR "\fIclock\fR\^(\|)",
.IR "\fIclock_getcpuclockid\fR\^(\|)",
.IR "\fIclock_getres\fR\^(\|)",
.IR "\fIclock_nanosleep\fR\^(\|)",
.IR "\fIctime\fR\^(\|)",
.IR "\fIdifftime\fR\^(\|)",
.IR "\fIgetdate\fR\^(\|)",
.IR "\fIgmtime\fR\^(\|)",
.IR "\fIlocaltime\fR\^(\|)",
.IR "\fImktime\fR\^(\|)",
.IR "\fImq_receive\fR\^(\|)",
.IR "\fImq_send\fR\^(\|)",
.IR "\fInanosleep\fR\^(\|)",
.IR "\fIpthread_getcpuclockid\fR\^(\|)",
.IR "\fIpthread_mutex_timedlock\fR\^(\|)",
.IR "\fIpthread_rwlock_timedrdlock\fR\^(\|)",
.IR "\fIpthread_rwlock_timedwrlock\fR\^(\|)",
.IR "\fIsem_timedwait\fR\^(\|)",
.IR "\fIstrftime\fR\^(\|)",
.IR "\fIstrptime\fR\^(\|)",
.IR "\fIsysconf\fR\^(\|)",
.IR "\fItime\fR\^(\|)",
.IR "\fItimer_create\fR\^(\|)",
.IR "\fItimer_delete\fR\^(\|)",
.IR "\fItimer_getoverrun\fR\^(\|)",
.IR "\fItzset\fR\^(\|)",
.IR "\fIutime\fR\^(\|)"
.ad b
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group.
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) 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.unix.org/online.html .
Any typographical or formatting errors that appear
in this page are most likely
to have been introduced during the conversion of the source files to
man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .
|