1time.h(0P)                 POSIX Programmer's Manual                time.h(0P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       time.h — time types
13

SYNOPSIS

15       #include <time.h>
16

DESCRIPTION

18       Some of the functionality described on this reference page extends  the
19       ISO C  standard. Applications shall define the appropriate feature test
20       macro (see the System Interfaces volume of POSIX.1‐2017,  Section  2.2,
21       The  Compilation Environment) to enable the visibility of these symbols
22       in this header.
23
24       The <time.h> header shall define the clock_t, size_t, time_t, types  as
25       described in <sys/types.h>.
26
27       The  <time.h>  header  shall  define the clockid_t and timer_t types as
28       described in <sys/types.h>.
29
30       The <time.h> header shall define the  locale_t  type  as  described  in
31       <locale.h>.
32
33       The  <time.h>  header  shall  define  the  pid_t  type  as described in
34       <sys/types.h>.
35
36       The tag sigevent shall be declared as naming  an  incomplete  structure
37       type, the contents of which are described in the <signal.h> header.
38
39       The <time.h> header shall declare the tm structure, which shall include
40       at least the following members:
41
42
43           int    tm_sec   Seconds [0,60].
44           int    tm_min   Minutes [0,59].
45           int    tm_hour  Hour [0,23].
46           int    tm_mday  Day of month [1,31].
47           int    tm_mon   Month of year [0,11].
48           int    tm_year  Years since 1900.
49           int    tm_wday  Day of week [0,6] (Sunday =0).
50           int    tm_yday  Day of year [0,365].
51           int    tm_isdst Daylight Savings flag.
52
53       The value of tm_isdst shall be positive if Daylight Savings Time is  in
54       effect,  0  if  Daylight Savings Time is not in effect, and negative if
55       the information is not available.
56
57       The <time.h> header shall declare the timespec structure,  which  shall
58       include at least the following members:
59
60
61           time_t  tv_sec    Seconds.
62           long    tv_nsec   Nanoseconds.
63
64       The  <time.h> header shall also declare the itimerspec structure, which
65       shall include at least the following members:
66
67
68           struct timespec  it_interval  Timer period.
69           struct timespec  it_value     Timer expiration.
70
71       The <time.h> header shall define the following macros:
72
73       NULL          As described in <stddef.h>.
74
75       CLOCKS_PER_SEC
76                     A number used  to  convert  the  value  returned  by  the
77                     clock()  function  into  seconds.  The  value shall be an
78                     expression   with   type   clock_t.    The    value    of
79                     CLOCKS_PER_SEC  shall be 1 million on XSI-conformant sys‐
80                     tems. However, it may be variable on other  systems,  and
81                     it  should  not  be assumed that CLOCKS_PER_SEC is a com‐
82                     pile-time constant.
83
84       The <time.h> header shall define the following symbolic constants.  The
85       values shall have a type that is assignment-compatible with clockid_t.
86
87       CLOCK_MONOTONIC
88                     The identifier for the system-wide monotonic clock, which
89                     is defined as a clock measuring real  time,  whose  value
90                     cannot  be  set via clock_settime() and which cannot have
91                     negative clock jumps. The  maximum  possible  clock  jump
92                     shall be implementation-defined.
93
94       CLOCK_PROCESS_CPUTIME_ID
95                     The  identifier of the CPU-time clock associated with the
96                     process making a clock() or timer*() function call.
97
98       CLOCK_REALTIME
99                     The identifier of the system-wide  clock  measuring  real
100                     time.
101
102       CLOCK_THREAD_CPUTIME_ID
103                     The  identifier of the CPU-time clock associated with the
104                     thread making a clock() or timer*() function call.
105
106       The <time.h> header shall define the following symbolic constant:
107
108       TIMER_ABSTIME Flag indicating time is absolute.  For  functions  taking
109                     timer  objects,  this refers to the clock associated with
110                     the timer.
111
112       The <time.h> header shall provide a declaration or definition for  get‐
113       date_err.  The getdate_err symbol shall expand to an expression of type
114       int.  It is unspecified whether getdate_err is a macro or an identifier
115       declared  with  external linkage, and whether or not it is a modifiable
116       lvalue. If a macro definition is  suppressed  in  order  to  access  an
117       actual  object,  or  a program defines an identifier with the name get‐
118       date_err, the behavior is undefined.
119
120       The following shall be declared as functions and may also be defined as
121       macros. Function prototypes shall be provided.
122
123
124           char      *asctime(const struct tm *);
125           char      *asctime_r(const struct tm *restrict, char *restrict);
126           clock_t    clock(void);
127           int        clock_getcpuclockid(pid_t, clockid_t *);
128           int        clock_getres(clockid_t, struct timespec *);
129           int        clock_gettime(clockid_t, struct timespec *);
130           int        clock_nanosleep(clockid_t, int, const struct timespec *,
131                          struct timespec *);
132           int        clock_settime(clockid_t, const struct timespec *);
133           char      *ctime(const time_t *);
134           char      *ctime_r(const time_t *, char *);
135           double     difftime(time_t, time_t);
136           struct tm *getdate(const char *);
137           struct tm *gmtime(const time_t *);
138           struct tm *gmtime_r(const time_t *restrict, struct tm *restrict);
139           struct tm *localtime(const time_t *);
140           struct tm *localtime_r(const time_t *restrict, struct tm *restrict);
141           time_t     mktime(struct tm *);
142           int        nanosleep(const struct timespec *, struct timespec *);
143           size_t     strftime(char *restrict, size_t, const char *restrict,
144                      const struct tm *restrict);
145           size_t     strftime_l(char *restrict, size_t, const char *restrict,
146                          const struct tm *restrict, locale_t);
147           char      *strptime(const char *restrict, const char *restrict,
148                          struct tm *restrict);
149           time_t     time(time_t *);
150           int        timer_create(clockid_t, struct sigevent *restrict,
151                          timer_t *restrict);
152           int        timer_delete(timer_t);
153           int        timer_getoverrun(timer_t);
154           int        timer_gettime(timer_t, struct itimerspec *);
155           int        timer_settime(timer_t, int, const struct itimerspec *restrict,
156                          struct itimerspec *restrict);
157           void       tzset(void);
158
159       The <time.h> header shall declare the following as variables:
160
161
162           extern int    daylight;
163           extern long   timezone;
164           extern char  *tzname[];
165
166       Inclusion  of the <time.h> header may make visible all symbols from the
167       <signal.h> header.
168
169       The following sections are informative.
170

APPLICATION USAGE

172       The range [0,60] for tm_sec allows for the occasional leap second.
173
174       tm_year is a signed value; therefore, years before 1900 may  be  repre‐
175       sented.
176
177       To  obtain the number of clock ticks per second returned by the times()
178       function, applications should call sysconf(_SC_CLK_TCK).
179

RATIONALE

181       The range [0,60] seconds allows for positive or negative leap  seconds.
182       The  formal  definition  of UTC does not permit double leap seconds, so
183       all mention of double leap seconds has  been  removed,  and  the  range
184       shortened  from  the  former [0,61] seconds seen in earlier versions of
185       this standard.
186

FUTURE DIRECTIONS

188       None.
189

SEE ALSO

191       <locale.h>, <signal.h>, <stddef.h>, <sys_types.h>
192
193       The System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compila‐
194       tion Environment, asctime(), clock(), clock_getcpuclockid(),
195       clock_getres(), clock_nanosleep(), ctime(), difftime(), getdate(),
196       gmtime(), localtime(), mktime(), mq_receive(), mq_send(), nanosleep(),
197       pthread_getcpuclockid(), pthread_mutex_timedlock(),
198       pthread_rwlock_timedrdlock(), pthread_rwlock_timedwrlock(), sem_timed‐
199       wait(), strftime(), strptime(), sysconf(), time(), timer_create(),
200       timer_delete(), timer_getoverrun(), tzset(), utime()
201
203       Portions  of  this text are reprinted and reproduced in electronic form
204       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
205       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
206       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
207       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
208       event of any discrepancy between this version and the original IEEE and
209       The  Open Group Standard, the original IEEE and The Open Group Standard
210       is the referee document. The original Standard can be  obtained  online
211       at http://www.opengroup.org/unix/online.html .
212
213       Any  typographical  or  formatting  errors that appear in this page are
214       most likely to have been introduced during the conversion of the source
215       files  to  man page format. To report such errors, see https://www.ker
216       nel.org/doc/man-pages/reporting_bugs.html .
217
218
219
220IEEE/The Open Group                  2017                           time.h(0P)
Impressum