MKTIME(3)                  POSIX Programmer's Manual                 MKTIME(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
       mktime -- convert broken-down time into time since the Epoch

SSYYNNOOPPSSIISS
       #include <time.h>

       time_t mktime(struct tm *_t_i_m_e_p_t_r);

DDEESSCCRRIIPPTTIIOONN
       The functionality described on this reference page is aligned with the
       ISO C standard. Any conflict between the requirements described here
       and the ISO C standard is unintentional. This volume of POSIX.1-2008
       defers to the ISO C standard.

       The _m_k_t_i_m_e() function shall convert the broken-down time, expressed as
       local time, in the structure pointed to by _t_i_m_e_p_t_r, into a time since
       the Epoch value with the same encoding as that of the values returned
       by _t_i_m_e().  The original values of the _t_m___w_d_a_y and _t_m___y_d_a_y components
       of the structure are ignored, and the original values of the other
       components are not restricted to the ranges described in _<_t_i_m_e_._h_>.

       A positive or 0 value for _t_m___i_s_d_s_t shall cause _m_k_t_i_m_e() to presume
       initially that Daylight Savings Time, respectively, is or is not in
       effect for the specified time. A negative value for _t_m___i_s_d_s_t shall
       cause _m_k_t_i_m_e() to attempt to determine whether Daylight Savings Time is
       in effect for the specified time.

       Local timezone information shall be set as though _m_k_t_i_m_e() called
       _t_z_s_e_t().

       The relationship between the ttmm structure (defined in the _<_t_i_m_e_._h_>
       header) and the time in seconds since the Epoch is that the result
       shall be as specified in the expression given in the definition of
       seconds since the Epoch (see the Base Definitions volume of
       POSIX.1-2008, _S_e_c_t_i_o_n _4_._1_5, _S_e_c_o_n_d_s _S_i_n_c_e _t_h_e _E_p_o_c_h) corrected for
       timezone and any seasonal time adjustments, where the names in the
       structure and in the expression correspond.

       Upon successful completion, the values of the _t_m___w_d_a_y and _t_m___y_d_a_y
       components of the structure shall be set appropriately, and the other
       components are set to represent the specified time since the Epoch, but
       with their values forced to the ranges indicated in the _<_t_i_m_e_._h_> entry;
       the final value of _t_m___m_d_a_y shall not be set until _t_m___m_o_n and _t_m___y_e_a_r
       are determined.

RREETTUURRNN VVAALLUUEE
       The _m_k_t_i_m_e() function shall return the specified time since the Epoch
       encoded as a value of type ttiimmee__tt.  If the time since the Epoch cannot
       be represented, the function shall return the value (ttiimmee__tt)-1 and set
       _e_r_r_n_o to indicate the error.

EERRRROORRSS
       The _m_k_t_i_m_e() function shall fail if:

       EEOOVVEERRFFLLOOWW
              The result cannot be represented.

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

EEXXAAMMPPLLEESS
       What day of the week is July 4, 2001?

           ##iinncclluuddee <<ssttddiioo..hh>>
           ##iinncclluuddee <<ttiimmee..hh>>

           struct tm time_str;

           char daybuf[20];

           int main(void)
           {
               time_str.tm_year = 2001 -- 1900;
               time_str.tm_mon = 7 -- 1;
               time_str.tm_mday = 4;
               time_str.tm_hour = 0;
               time_str.tm_min = 0;
               time_str.tm_sec = 1;
               time_str.tm_isdst = -1;
               if (mktime(&time_str) == -1)
                   (void)puts("-unknown-");
               else {
                   (void)strftime(daybuf, sizeof(daybuf), "%A", &time_str);
                   (void)puts(daybuf);
               }
               return 0;
           }

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _a_s_c_t_i_m_e(), _c_l_o_c_k(), _c_t_i_m_e(), _d_i_f_f_t_i_m_e(), _g_m_t_i_m_e(), _l_o_c_a_l_t_i_m_e(),
       _s_t_r_f_t_i_m_e(), _s_t_r_p_t_i_m_e(), _t_i_m_e(), _t_z_s_e_t(), _u_t_i_m_e()

       The Base Definitions volume of POSIX.1-2008, _S_e_c_t_i_o_n _4_._1_5, _S_e_c_o_n_d_s
       _S_i_n_c_e _t_h_e _E_p_o_c_h, <<ttiimmee..hh>>

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



IEEE/The Open Group                  2013                            MKTIME(3)
