Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/man/man3c/mktime.3c
Real path: /usr/share/man/man3c/mktime.3c
Zurück
'\" te .\" Copyright (c) 2003, 2021, Oracle and/or its affiliates. .\" Copyright (c) 1989, AT&T. All rights reserved. .\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All rights reserved. .\" Oracle gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions 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. This notice shall appear on any product containing this material. .TH mktime 3C "11 May 2021" "Oracle Solaris 11.4" "Standard C Library Functions" .SH NAME mktime, timegm, timelocal \- converts a \fBtm\fR structure to a calendar time .SH SYNOPSIS .LP .nf #include <time.h> .fi .LP .nf \fBtime_t\fR \fBmktime\fR(\fBstruct tm *\fR\fItimeptr\fR); .fi .LP .nf time_t timegm(struct tm *\fItimeptr\fR); .fi .LP .nf time_t timelocal(struct tm *\fItimeptr\fR); .fi .SH DESCRIPTION .sp .LP The \fBmktime()\fR, \fBtimegm()\fR, and \fBtimelocal()\fR functions convert the time represented by the \fBtm\fR structure pointed to by \fItimeptr\fR into a calendar time (the number of seconds since 00:00:00 UTC, January 1, 1970). .sp .LP The \fBtm\fR structure contains the following members: .sp .in +2 .nf int tm_sec; /* seconds after the minute [0, 60] */ int tm_min; /* minutes after the hour [0, 59] */ int tm_hour; /* hour since midnight [0, 23] */ int tm_mday; /* day of the month [1, 31] */ int tm_mon; /* months since January [0, 11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0, 6] */ int tm_yday; /* days since January 1 [0, 365] */ int tm_isdst; /* flag for daylight savings time */ .fi .in -2 .sp .sp .LP In addition to computing the calendar time, \fBmktime()\fR, \fBtimegm()\fR, and \fBtimelocal()\fR normalize the supplied \fBtm\fR structure. The original values of the \fBtm_wday\fR and \fBtm_yday\fR components of the structure are ignored, and the original values of the other components are not restricted to the ranges indicated in the definition of the structure. On successful completion, the values of the \fBtm_wday\fR and \fBtm_yday\fR components are set appropriately, and the other components are set to represent the specified calendar time, but with their values forced to be within the appropriate ranges. The final value of \fBtm_mday\fR is not set until \fBtm_mon\fR and \fBtm_year\fR are determined. .sp .LP Calendar time in a 32-bit application cannot represent values before 20:45:52 UTC, December 13, 1901 or after 03:14:07 UTC, January 19, 2038. As the \fBtm_year\fR member is a signed integer, calendar time in a 64-bit application cannot represent years before 2147483649 BC or after 2147485546 AD. Portable applications should not try to create dates before 00:00:00 UTC, January 1, 1970 or after 00:00:00 UTC, January 1, 2038. Where practical 64-bit applications should limit themselves to dates in the range 00:00:00 UTC, January 1, 1970 to 00:00:00 UTC, December 31, 9999. .sp .LP The original values of the components may be either greater than or less than the specified range. For example, a \fBtm_hour\fR of \(mi1 means 1 hour before midnight, \fBtm_mday\fR of 0 means the day preceding the current month, and \fBtm_mon\fR of \(mi2 means 2 months before January of \fBtm_year\fR. .sp .LP If \fBtm_isdst\fR is positive, \fBmktime()\fR assumes the original values to be in the alternate time zone. If it turns out that the alternate time zone is not valid for the computed calendar time, then the components are adjusted to the main time zone. Likewise, if \fBtm_isdst\fR is zero, the original values are assumed to be in the main time zone and are converted to the alternate time zone if the main time zone is not valid. If \fBtm_isdst\fR is negative, \fBmktime()\fR attempts to determine whether the alternate time zone is in effect for the specified time. \fBtimelocal()\fR is equivalent to \fBmktime()\fR with a negative \fBtm_isdst\fR value. .sp .LP Local time zone information is used as if \fBmktime()\fR or \fBtimelocal()\fR had called \fBtzset()\fR. See \fBctime\fR(3C). .sp .LP The function \fBtimegm()\fR performs the inverse conversion to \fBgmtime()\fR and ignores the local time zone information. The original values are assumed to be in the UTC time zone. See \fBctime\fR(3C). .SH RETURN VALUES .sp .LP If the calendar time can be represented in an object of type \fBtime_t\fR, then \fBmktime()\fR, \fBtimegm()\fR, and \fBtimelocal()\fR return the specified calendar time without changing \fBerrno\fR. If the calendar time cannot be represented, the functions return the value (\fBtime_t\fR)\e(\fBmi1\fR) and set \fBerrno\fR to indicate the error. .SH ERRORS .sp .LP The \fBmktime()\fR, \fBtimegm()\fR, and \fBtimelocal()\fR functions will fail if: .sp .ne 2 .mk .na \fB\fBEOVERFLOW\fR\fR .ad .RS 13n .rt The date represented by the input \fBtm\fR struct cannot be represented in a \fBtime_t\fR. Note that the \fBerrno\fR setting may change if future revisions to the standards specify a different value. .RE .SH USAGE .sp .LP The \fBmktime()\fR and \fBtimelocal()\fR functions are MT-Safe in multithreaded applications, as long as no user-defined function directly modifies one of the following variables: \fBtimezone\fR, \fBaltzone\fR, \fBdaylight\fR, and \fBtzname\fR. See \fBctime\fR(3C). The \fBtimegm()\fR function is MT-Safe in multithreaded applications. .sp .LP Note that \(mi1 can be a valid return value for the time that is one second before the Epoch. The user should clear \fBerrno\fR before calling \fBmktime()\fR. If \fBmktime()\fR then returns \(mi1, the user should check \fBerrno\fR to determine whether or not an error actually occurred. .sp .LP The \fBmktime()\fR, \fBtimegm()\fR, and \fBtimelocal()\fR functions assume Gregorian dates. Times before the adoption of the Gregorian calendar will not match historical records. .SH EXAMPLES .LP \fBExample 1\fR Sample code using \fBmktime()\fR. .sp .LP What day of the week is July 4, 2001? .sp .in +2 .nf #include <stdio.h> #include <time.h> static char *const wday[\|] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "-unknown-" }; struct tm time_str; /*\|.\|.\|.*/ 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 = \(mi1; if (mktime(&time_str)== \(mi1) time_str.tm_wday=7; printf("%s\en", wday[time_str.tm_wday]); .fi .in -2 .sp .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .TS tab( ) box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed _ MT-Level MT-Safe with exceptions _ Standard See \fBstandards\fR(7). .TE .sp .SH SEE ALSO .sp .LP \fBctime\fR(3C), \fBgetenv\fR(3C), \fBattributes\fR(7), \fBstandards\fR(7)