Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/lib/ape/man/3/mktime

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "MKTIME" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" mktime 
.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
mktime \- convert broken-down time into time since the Epoch
.SH SYNOPSIS
.LP
\fB#include <time.h>
.br
.sp
time_t mktime(struct tm *\fP\fItimeptr\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
The \fImktime\fP() function shall convert the broken-down time, expressed
as local time, in the structure pointed to by
\fItimeptr\fP, into a time since the Epoch value with the same encoding
as that of the values returned by \fItime\fP(). The original values
of the \fItm_wday\fP and \fItm_yday\fP components of the
structure are ignored, and the original values of the other components
are not restricted to the ranges described in \fI<time.h>\fP.
.LP
A
positive or 0 value for \fItm_isdst\fP shall cause \fImktime\fP()
to presume initially that Daylight Savings Time, respectively,
is or is not in effect for the specified time. A negative value for
\fItm_isdst\fP shall cause \fImktime\fP() to attempt to
determine whether Daylight Savings Time is in effect for the specified
time.
.LP
Local timezone information shall be set as though \fImktime\fP() called
\fItzset\fP().
.LP
The relationship between the \fBtm\fP structure (defined in the \fI<time.h>\fP
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 IEEE\ Std\ 1003.1-2001,
Section 4.14, Seconds Since the Epoch) corrected for timezone and
any seasonal time
adjustments, where the names in the structure and in the expression
correspond. 
.LP
Upon successful completion, the values of the \fItm_wday\fP and \fItm_yday\fP
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 \fI<time.h>\fP entry; the final value
of \fItm_mday\fP
shall not be set until \fItm_mon\fP and \fItm_year\fP are determined.
.SH RETURN VALUE
.LP
The \fImktime\fP() function shall return the specified time since
the Epoch encoded as a value of type \fBtime_t\fP. If the
time since the Epoch cannot be represented, the function shall return
the value (\fBtime_t\fP)-1.
.SH ERRORS
.LP
No errors are defined.
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
What day of the week is July 4, 2001?
.sp
.RS
.nf

\fB#include <stdio.h>
#include <time.h>
.sp

struct tm time_str;
.sp

char daybuf[20];
.sp

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;
}
\fP
.fi
.RE
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIasctime\fP(), \fIclock\fP(), \fIctime\fP(),
\fIdifftime\fP(), \fIgmtime\fP(), \fIlocaltime\fP(), \fIstrftime\fP(),
\fIstrptime\fP(), \fItime\fP(), \fIutime\fP(), the Base
Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<time.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 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 .

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].