<!DOCTYPE html PUBLIC "‐//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">     <html
xmlns="http://www.w3.org/1999/xhtml"> <head>
    <link            rel="stylesheet"             type="text/css"
href="../../../style.css" title="style" />
    <link  rel="stylesheet"  type="text/css"  href="../style.css"
title="style" />
    <meta             http‐equiv="content‐type"              con‐
tent="text/html;charset=utf‐8" />

    <title>time.h.0p ‐ Linux manual page</title> </head>

<body>

<div        class="page‐top"><a       id="top_of_page"></a></div>
<!‐‐%%%TOP_BAR%%%‐‐> <!‐‐%%%PAGE_START%%%‐‐>

<table class="sec‐table"> <tr>
    <td>
        <p class="section‐dir"> <a href="#PROLOG">PROLOG</a> | <a
href="#NAME">NAME</a>  |  <a  href="#SYNOPSIS">SYNOPSIS</a>  | <a
href="#DESCRIPTION">DESCRIPTION</a> |  <a  href="#APPLICATION_US‐
AGE">APPLICATION&nbsp;USAGE</a>   |  <a  href="#RATIONALE">RATIO‐
NALE</a>   |   <a    href="#FUTURE_DIRECTIONS">FUTURE&nbsp;DIREC‐
TIONS</a>    |   <a   href="#SEE_ALSO">SEE&nbsp;ALSO</a>   |   <a
href="#COPYRIGHT">COPYRIGHT</a>
        </p>
    </td>
    <td class="search‐box">
        <div class="man‐search‐box">

            <form                method="get"                 ac‐
tion="http://www.google.com/search">
                <fieldset class="man‐search">
                    <input    type="text"    name="q"   size="10"
maxlength="255" value="" />
                    <input type="hidden"  name="sitesearch"  val‐
ue="man7.org/linux/man‐pages" />
                    <input  type="submit" name="sa" value="Search
online pages" />
                </fieldset>
            </form>

        </div>
    </td>
    <td> </td> </tr> </table>

<pre> <span class="headline">time.h(0P)                POSIX Pro‐
grammer’s  Manual                time.h(0P)</span>  </pre> <h2><a
id="PROLOG" href="#PROLOG"></a>PROLOG  &nbsp; &nbsp; &nbsp;  &nb‐
sp;        <a        href="#top_of_page"><span        class="top‐
link">top</span></a></h2><pre>
       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 be‐
havior), or
       the interface may not be  implemented  on  Linux.   </pre>
<h2><a id="NAME" href="#NAME"></a>NAME  &nbsp; &nbsp; &nbsp; &nb‐
sp;        <a        href="#top_of_page"><span        class="top‐
link">top</span></a></h2><pre>
       time.h   —   time   types   </pre>   <h2><a  id="SYNOPSIS"
href="#SYNOPSIS"></a>SYNOPSIS  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       #include  &lt;time.h&gt;  </pre>  <h2><a  id="DESCRIPTION"
href="#DESCRIPTION"></a>DESCRIPTION   &nbsp; &nbsp; &nbsp; &nbsp;
<a             href="#top_of_page"><span              class="top‐
link">top</span></a></h2><pre>
       Some of the functionality described on this reference page
extends
       the ISO C standard. Applications shall define  the  appro‐
priate feature
       test   macro   (see   the   System  Interfaces  volume  of
POSIX.1‐2008, <i>Section</i>
       <i>2.2</i>, <i>The Compilation Environment</i>) to  enable
the visibility of these
       symbols in this header.

       The   <i>&lt;time.h&gt;</i>   header   shall   define  the
<b>clock_t</b>, <b>size_t</b>, <b>time_t</b>, types
       as described in <i>&lt;sys/types.h&gt;</i>.

       The  <i>&lt;time.h&gt;</i>   header   shall   define   the
<b>clockid_t </b>and <b>timer_t </b>types as
       described in <i>&lt;sys/types.h&gt;</i>.

       The  <i>&lt;time.h&gt;</i>  header shall define the <b>lo‐
cale_t </b>type as described in
       <i>&lt;locale.h&gt;</i>.

       The <i>&lt;time.h&gt;</i> header shall define the <b>pid_t
</b>type as described in
       <i>&lt;sys/types.h&gt;</i>.

       The tag <b>sigevent </b>shall be declared as naming an in‐
complete structure
       type,  the  contents  of  which  are  described   in   the
<i>&lt;signal.h&gt;</i> header.

       The  <i>&lt;time.h&gt;</i>  header shall declare the <b>tm
</b>structure, which shall
       include at least the following members:

           <b>int    tm_sec   </b>Seconds [0,60].
           int    tm_min   Minutes [0,59].
           int    tm_hour  Hour [0,23].
           int    tm_mday  Day of month [1,31].
           int    tm_mon   Month of year [0,11].
           int    tm_year  Years since 1900.
           int    tm_wday  Day of week [0,6] (Sunday =0).
           int    tm_yday  Day of year [0,365].
           int    tm_isdst Daylight Savings flag.

       The value of <i>tm_isdst</i> 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.

       The  <i>&lt;time.h&gt;</i>  header   shall   declare   the
<b>timespec </b>structure, which shall
       include at least the following members:

           <b>time_t  tv_sec    </b>Seconds.
           long    tv_nsec   Nanoseconds.

       The  <i>&lt;time.h&gt;</i>  header  shall also declare the
<b>itimerspec </b>structure,
       which shall include at least the following members:

           <b>struct timespec  it_interval  </b>Timer period.
           struct timespec  it_value     Timer expiration.

       The <i>&lt;time.h&gt;</i> header shall define the  follow‐
ing macros:

       NULL          As described in <i>&lt;stddef.h&gt;</i>.

       CLOCKS_PER_SEC
                     A  number used to convert the value returned
by the
                     <i>clock</i>() function  into  seconds.  The
value shall be an
                     expression  with  type  <b>clock_t</b>.  The
value of
                     CLOCKS_PER_SEC shall be 1  million  on  XSI‐
conformant
                     systems. However, it may be variable on oth‐
er systems,
                     and  it   should   not   be   assumed   that
CLOCKS_PER_SEC is a
                     compile‐time constant.

       The  <i>&lt;time.h&gt;</i> header shall define the follow‐
ing symbolic constants.
       The values shall have a type that is assignment‐compatible
with
       <b>clockid_t</b>.

       CLOCK_MONOTONIC
                     The identifier for the system‐wide monotonic
clock,
                     which is defined as a clock  measuring  real
time, whose
                     value   cannot   be  set  via  <i>clock_set‐
time</i>() and which
                     cannot have negative clock jumps. The  maxi‐
mum possible
                     clock jump shall be implementation‐defined.

       CLOCK_PROCESS_CPUTIME_ID
                     The identifier of the CPU‐time clock associ‐
ated with
                     the  process  making  a  <i>clock</i>()   or
<i>timer*</i>() function call.

       CLOCK_REALTIME
                     The identifier of the system‐wide clock mea‐
suring real
                     time.

       CLOCK_THREAD_CPUTIME_ID
                     The identifier of the CPU‐time clock associ‐
ated with
                     the   thread   making  a  <i>clock</i>()  or
<i>timer*</i>() function call.

       The <i>&lt;time.h&gt;</i> header shall define the  follow‐
ing symbolic constant:

       TIMER_ABSTIME  Flag indicating time is absolute. For func‐
tions taking
                     timer objects, this refers to the clock  as‐
sociated with
                     the timer.

       The  <i>&lt;time.h&gt;</i> header shall provide a declara‐
tion or definition for
       <i>getdate_err</i>.  The <i>getdate_err</i>  symbol  shall
expand to an expression of
       type   <b>int</b>.   It  is  unspecified  whether  <i>get‐
date_err</i> 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 identifi‐
er with the
       name <i>getdate_err</i>, the behavior is undefined.

       The  following shall be declared as functions and may also
be defined
       as macros. Function prototypes shall be provided.

           <b>char      *asctime(const struct tm *);</b>
           <b>char       *asctime_r(const  struct  tm  *restrict,
char *restrict);</b>
           <b>clock_t    clock(void);</b>
           <b>int          clock_getcpuclockid(pid_t,   clockid_t
*);</b>
           <b>int        clock_getres(clockid_t, struct  timespec
*);</b>
           <b>int        clock_gettime(clockid_t, struct timespec
*);</b>
           <b>int         clock_nanosleep(clockid_t,  int,  const
struct timespec *,</b>
                          <b>struct timespec *);</b>
           <b>int         clock_settime(clockid_t,  const  struct
timespec *);</b>
           <b>char      *ctime(const time_t *);</b>
           <b>char      *ctime_r(const time_t *, char *);</b>
           <b>double     difftime(time_t, time_t);</b>
           <b>struct tm *getdate(const char *);</b>
           <b>struct tm *gmtime(const time_t *);</b>
           <b>struct tm *gmtime_r(const time_t *restrict,  struct
tm *restrict);</b>
           <b>struct tm *localtime(const time_t *);</b>
           <b>struct   tm  *localtime_r(const  time_t  *restrict,
struct tm *restrict);</b>
           <b>time_t     mktime(struct tm *);</b>
           <b>int         nanosleep(const  struct   timespec   *,
struct timespec *);</b>
           <b>size_t      strftime(char  *restrict, size_t, const
char *restrict,</b>
                      <b>const struct tm *restrict);</b>
           <b>size_t     strftime_l(char *restrict, size_t, const
char *restrict,</b>
                          <b>const   struct   tm  *restrict,  lo‐
cale_t);</b>
           <b>char       *strptime(const  char  *restrict,  const
char *restrict,</b>
                          <b>struct tm *restrict);</b>
           <b>time_t     time(time_t *);</b>
           <b>int         timer_create(clockid_t, struct sigevent
*restrict,</b>
                          <b>timer_t *restrict);</b>
           <b>int        timer_delete(timer_t);</b>
           <b>int        timer_getoverrun(timer_t);</b>
           <b>int        timer_gettime(timer_t, struct itimerspec
*);</b>
           <b>int        timer_settime(timer_t, int, const struct
itimerspec *restrict,</b>
                          <b>struct itimerspec *restrict);</b>
           <b>void       tzset(void);</b>

       The <i>&lt;time.h&gt;</i> header shall declare the follow‐
ing as variables:

           <b>extern int    daylight;</b>
           <b>extern long   timezone;</b>
           <b>extern char  *tzname[];</b>

       Inclusion  of  the  <i>&lt;time.h&gt;</i>  header may make
visible all symbols from
       the <i>&lt;signal.h&gt;</i> header.

       <i>The  following  sections  are  informative.</i>  </pre>
<h2><a  id="APPLICATION_USAGE"  href="#APPLICATION_USAGE"></a>AP‐
PLICATION    USAGE     &nbsp;    &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       The range [0,60] for <i>tm_sec</i> allows  for  the  occa‐
sional leap second.

       <i>tm_year</i>  is a signed value; therefore, years before
1900 may be
       represented.

       To obtain the number of clock ticks per second returned by
the
       <i>times</i>()    function,   applications   should   call
<i>sysconf</i>(_SC_CLK_TCK).    </pre>   <h2><a    id="RATIONALE"
href="#RATIONALE"></a>RATIONALE   &nbsp;  &nbsp; &nbsp; &nbsp; <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       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.  </pre> <h2><a id="FUTURE_DI‐
RECTIONS" href="#FUTURE_DIRECTIONS"></a>FUTURE DIRECTIONS  &nbsp;
&nbsp;  &nbsp;  &nbsp;  <a  href="#top_of_page"><span class="top‐
link">top</span></a></h2><pre>
       None.    </pre>   <h2><a   id="SEE_ALSO"    href="#SEE_AL‐
SO"></a>SEE    ALSO     &nbsp;    &nbsp;    &nbsp;    &nbsp;   <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       <a   href="../man0/locale.h.0p.html">locale.h(0p)</a>,  <a
href="../man0/signal.h.0p.html">signal.h(0p)</a>,              <a
href="../man0/stddef.h.0p.html">stddef.h(0p)</a>,              <a
href="../man0/sys_types.h.0p.html">sys_types.h(0p)</a>

       The System Interfaces volume of  POSIX.1‐2008,  <i>Section
2.2</i>, <i>The</i>
       <i>Compilation   Environment</i>,   <a  href="../man3/asc‐
time.3p.html">asctime(3p)</a>,                                 <a
href="../man3/clock.3p.html">clock(3p)</a>,
       <a                        href="../man3/clock_getcpuclock‐
id.3p.html">clock_getcpuclockid(3p)</a>,                       <a
href="../man3/clock_getres.3p.html">clock_getres(3p)</a>,      <a
href="../man3/clock_nanosleep.3p.html">clock_nanosleep(3p)</a>,
       <a     href="../man3/ctime.3p.html">ctime(3p)</a>,      <a
href="../man3/difftime.3p.html">difftime(3p)</a>,              <a
href="../man3/getdate.3p.html">getdate(3p)</a>,                <a
href="../man3/gmtime.3p.html">gmtime(3p)</a>,                  <a
href="../man3/localtime.3p.html">localtime(3p)</a>,
       <a    href="../man3/mktime.3p.html">mktime(3p)</a>,     <a
href="../man3/mq_receive.3p.html">mq_receive(3p)</a>,          <a
href="../man3/mq_send.3p.html">mq_send(3p)</a>,                <a
href="../man3/nanosleep.3p.html">nanosleep(3p)</a>,
       <a                      href="../man3/pthread_getcpuclock‐
id.3p.html">pthread_getcpuclockid(3p)</a>,                     <a
href="../man3/pthread_mutex_timedlock.3p.html">pthread_mu‐
tex_timedlock(3p)</a>,
       <a                   href="../man3/pthread_rwlock_timedrd‐
lock.3p.html">pthread_rwlock_timedrdlock(3p)</a>,              <a
href="../man3/pthread_rwlock_timedwr‐
lock.3p.html">pthread_rwlock_timedwrlock(3p)</a>,
       <a         href="../man3/sem_timedwait.3p.html">sem_timed‐
wait(3p)</a>,      <a       href="../man3/strftime.3p.html">strf‐
time(3p)</a>,       <a      href="../man3/strptime.3p.html">strp‐
time(3p)</a>, <a  href="../man3/sysconf.3p.html">sysconf(3p)</a>,
<a href="../man3/time.3p.html">time(3p)</a>,
       <a          href="../man3/timer_create.3p.html">timer_cre‐
ate(3p)</a>,                                                   <a
href="../man3/timer_delete.3p.html">timer_delete(3p)</a>,      <a
href="../man3/timer_getoverrun.3p.html">timer_getoverrun(3p)</a>,
<a href="../man3/tzset.3p.html">tzset(3p)</a>,
       <a    href="../man3/utime.3p.html">utime(3p)</a>    </pre>
<h2><a  id="COPYRIGHT"  href="#COPYRIGHT"></a>COPYRIGHT    &nbsp;
&nbsp;  &nbsp;  &nbsp;  <a  href="#top_of_page"><span class="top‐
link">top</span></a></h2><pre>
       Portions of this text  are  reprinted  and  reproduced  in
electronic form
       from  IEEE Std 1003.1, 2013 Edition, Standard for Informa‐
tion
       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 Cor‐
rigendum 1
       applied.) In the event of  any  discrepancy  between  this
version and
       the  original IEEE and The Open Group Standard, the origi‐
nal IEEE and
       The Open Group Standard is the referee document. The orig‐
inal
       Standard     can     be     obtained    online    at    <a
href="http://www.unix.org/online.html">http://www.unix.org/on‐
line.html</a> .

       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
       <a      href="https://www.kernel.org/doc/man‐pages/report‐
ing_bugs.html">https://www.kernel.org/doc/man‐pages/report‐
ing_bugs.html</a> .

<span class="footline">IEEE/The Open  Group                  2013
time.h(0P)</span> </pre>

<hr class="end‐man‐text" />

<hr class="start‐footer" />

<div class="footer">

<table class="colophon‐table">
    <tr>
    <td class="pub‐info">
        <p>
            HTML rendering created 2019‐08‐02
            by  <a  href="http://man7.org/mtk/index.html">Michael
Kerrisk</a>,
            author of
            <a  href="http://man7.org/tlpi/"><em>The  Linux  Pro‐
gramming Interface</em></a>,
            maintainer of the
            <a href="https://www.kernel.org/doc/man‐pages/">Linux
<em>man‐pages</em> project</a>.
        </p>
        <p>
            For details of in‐depth
            <strong>Linux/UNIX system programming training  cour‐
ses</strong>
            that  I  teach,  look <a href="http://man7.org/train‐
ing/">here</a>.
        </p>
        <p>
            Hosting   by    <a    href="http://www.jambit.com/in‐
dex_en.html">jambit GmbH</a>.
        </p>
        <p>
            <a href="http://validator.w3.org/check?uri=referer">
            <img src="http://www.w3.org/Icons/valid‐xhtml11"
                alt="Valid XHTML 1.1" height="31" width="88" />
            </a>
        </p>
    </td>
    <td class="colophon‐divider">
    </td>
    <td class="tlpi‐cover">
        <a                      href="http://man7.org/tlpi/"><img
src="http://man7.org/tlpi/cover/TLPI‐front‐cover‐vsmall.png"
alt="Cover of TLPI" /></a>
    </td>
    </tr> </table>

</div>

<hr class="end‐footer" />

</body> </html>