time.h(3)                  POSIX Programmer's Manual                 time.h(3)



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

NNAAMMEE
       time.h -- time types

SSYYNNOOPPSSIISS
       #include <time.h>

DDEESSCCRRIIPPTTIIOONN
       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-2017, _S_e_c_t_i_o_n _2_._2,
       _T_h_e _C_o_m_p_i_l_a_t_i_o_n _E_n_v_i_r_o_n_m_e_n_t) to enable the visibility of these symbols
       in this header.

       The _<_t_i_m_e_._h_> header shall define the cclloocckk__tt, ssiizzee__tt, ttiimmee__tt, types as
       described in _<_s_y_s_/_t_y_p_e_s_._h_>.

       The _<_t_i_m_e_._h_> header shall define the cclloocckkiidd__tt and ttiimmeerr__tt types as
       described in _<_s_y_s_/_t_y_p_e_s_._h_>.

       The _<_t_i_m_e_._h_> header shall define the llooccaallee__tt type as described in
       _<_l_o_c_a_l_e_._h_>.

       The _<_t_i_m_e_._h_> header shall define the ppiidd__tt type as described in
       _<_s_y_s_/_t_y_p_e_s_._h_>.

       The tag ssiiggeevveenntt shall be declared as naming an incomplete structure
       type, the contents of which are described in the _<_s_i_g_n_a_l_._h_> header.

       The _<_t_i_m_e_._h_> header shall declare the ttmm structure, which shall include
       at least the following members:


           int    tm_sec   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 _t_m___i_s_d_s_t 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 _<_t_i_m_e_._h_> header shall declare the ttiimmeessppeecc structure, which shall
       include at least the following members:


           time_t  tv_sec    Seconds.
           long    tv_nsec   Nanoseconds.

       The _<_t_i_m_e_._h_> header shall also declare the iittiimmeerrssppeecc structure, which
       shall include at least the following members:


           struct timespec  it_interval  Timer period.
           struct timespec  it_value     Timer expiration.

       The _<_t_i_m_e_._h_> header shall define the following macros:

       NULL          As described in _<_s_t_d_d_e_f_._h_>.

       CLOCKS_PER_SEC
                     A number used to convert the value returned by the
                     _c_l_o_c_k() function into seconds. The value shall be an
                     expression with type cclloocckk__tt.  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.

       The _<_t_i_m_e_._h_> header shall define the following symbolic constants. The
       values shall have a type that is assignment-compatible with cclloocckkiidd__tt.

       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 _c_l_o_c_k___s_e_t_t_i_m_e() and which cannot have
                     negative clock jumps. The maximum possible clock jump
                     shall be implementation-defined.

       CLOCK_PROCESS_CPUTIME_ID
                     The identifier of the CPU-time clock associated with the
                     process making a _c_l_o_c_k() or _t_i_m_e_r_*() function call.

       CLOCK_REALTIME
                     The identifier of the system-wide clock measuring real
                     time.

       CLOCK_THREAD_CPUTIME_ID
                     The identifier of the CPU-time clock associated with the
                     thread making a _c_l_o_c_k() or _t_i_m_e_r_*() function call.

       The _<_t_i_m_e_._h_> header shall define the following symbolic constant:

       TIMER_ABSTIME Flag indicating time is absolute. For functions taking
                     timer objects, this refers to the clock associated with
                     the timer.

       The _<_t_i_m_e_._h_> header shall provide a declaration or definition for
       _g_e_t_d_a_t_e___e_r_r.  The _g_e_t_d_a_t_e___e_r_r symbol shall expand to an expression of
       type iinntt.  It is unspecified whether _g_e_t_d_a_t_e___e_r_r 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 _g_e_t_d_a_t_e___e_r_r, the behavior is undefined.

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


           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);

       The _<_t_i_m_e_._h_> header shall declare the following as variables:


           extern int    daylight;
           extern long   timezone;
           extern char  *tzname[];

       Inclusion of the _<_t_i_m_e_._h_> header may make visible all symbols from the
       _<_s_i_g_n_a_l_._h_> header.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The range [0,60] for _t_m___s_e_c allows for the occasional leap second.

       _t_m___y_e_a_r is a signed value; therefore, years before 1900 may be
       represented.

       To obtain the number of clock ticks per second returned by the _t_i_m_e_s()
       function, applications should call _s_y_s_c_o_n_f(_SC_CLK_TCK).

RRAATTIIOONNAALLEE
       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.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       <<llooccaallee..hh>>, <<ssiiggnnaall..hh>>, <<ssttddddeeff..hh>>, <<ssyyss__ttyyppeess..hh>>

       The System Interfaces volume of POSIX.1-2017, _S_e_c_t_i_o_n _2_._2, _T_h_e
       _C_o_m_p_i_l_a_t_i_o_n _E_n_v_i_r_o_n_m_e_n_t, _a_s_c_t_i_m_e(), _c_l_o_c_k(), _c_l_o_c_k___g_e_t_c_p_u_c_l_o_c_k_i_d(),
       _c_l_o_c_k___g_e_t_r_e_s(), _c_l_o_c_k___n_a_n_o_s_l_e_e_p(), _c_t_i_m_e(), _d_i_f_f_t_i_m_e(), _g_e_t_d_a_t_e(),
       _g_m_t_i_m_e(), _l_o_c_a_l_t_i_m_e(), _m_k_t_i_m_e(), _m_q___r_e_c_e_i_v_e(), _m_q___s_e_n_d(), _n_a_n_o_s_l_e_e_p(),
       _p_t_h_r_e_a_d___g_e_t_c_p_u_c_l_o_c_k_i_d(), _p_t_h_r_e_a_d___m_u_t_e_x___t_i_m_e_d_l_o_c_k(),
       _p_t_h_r_e_a_d___r_w_l_o_c_k___t_i_m_e_d_r_d_l_o_c_k(), _p_t_h_r_e_a_d___r_w_l_o_c_k___t_i_m_e_d_w_r_l_o_c_k(),
       _s_e_m___t_i_m_e_d_w_a_i_t(), _s_t_r_f_t_i_m_e(), _s_t_r_p_t_i_m_e(), _s_y_s_c_o_n_f(), _t_i_m_e(),
       _t_i_m_e_r___c_r_e_a_t_e(), _t_i_m_e_r___d_e_l_e_t_e(), _t_i_m_e_r___g_e_t_o_v_e_r_r_u_n(), _t_z_s_e_t(), _u_t_i_m_e()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 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 .

       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 .



IEEE/The Open Group                  2017                            time.h(3)
