mktime.html
来自「unix 下的C开发手册,还用详细的例程。」· HTML 代码 · 共 142 行
HTML
142 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>mktime</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_669"> </a>NAME</h4><blockquote>mktime - convert broken-down time into time since the Epoch</blockquote><h4><a name = "tag_000_007_670"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="time.h.html">time.h</a>>time_t mktime(struct tm *<i>timeptr</i>);</code></pre></blockquote><h4><a name = "tag_000_007_671"> </a>DESCRIPTION</h4><blockquote>The<i>mktime()</i>function converts the broken-down time, expressed as local time,in the structure pointed to by<i>timeptr</i>,into a time since the Epoch value with the same encoding as that of thevalues returned by<i><a href="time.html">time()</a></i>.The original values of the<i>tm_wday</i>and<i>tm_yday</i>components of the structure are ignored, and the original valuesof the other components are not restricted to the rangesdescribed in the<i><a href="time.h.html"><time.h></a></i>entry.<p>A positive or 0 value for<i>tm_isdst</i>causes<i>mktime()</i>to presume initially that Daylight Savings Time, respectively, is or is not ineffect for the specified time. A negative value for<i>tm_isdst</i>causes<i>mktime()</i>to attempt to determine whether Daylight Saving Time isin effect for the specified time.<p>Local timezone information is set as though<i>mktime()</i>called<i><a href="tzset.html">tzset()</a></i>.<p>Upon successful completion, the values of the<i>tm_wday</i>and<i>tm_yday</i>components of the structure are set appropriately, and the othercomponents are set to represent the specified time since the Epoch, butwith their values forced to the ranges indicated in the<i><a href="time.h.html"><time.h></a></i>entry; the final value of<i>tm_mday</i>is not set until<i>tm_mon</i>and<i>tm_year</i>are determined.</blockquote><h4><a name = "tag_000_007_672"> </a>RETURN VALUE</h4><blockquote>The<i>mktime()</i>function returns the specified time since the Epoch encoded as a valueof type<b>time_t</b>.If the time since the Epoch cannot be represented, the function returnsthe value(<b>time_t</b>)-1.</blockquote><h4><a name = "tag_000_007_673"> </a>ERRORS</h4><blockquote>No errors are defined.</blockquote><h4><a name = "tag_000_007_674"> </a>EXAMPLES</h4><blockquote>What day of the week is July 4, 2001?<pre><code>#include <stdio.h>#include <time.h>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;}</code></pre></blockquote><h4><a name = "tag_000_007_675"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_676"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_677"> </a>SEE ALSO</h4><blockquote><i><a href="asctime.html">asctime()</a></i>,<i><a href="clock.html">clock()</a></i>,<i><a href="ctime.html">ctime()</a></i>,<i><a href="difftime.html">difftime()</a></i>,<i><a href="gmtime.html">gmtime()</a></i>,<i><a href="localtime.html">localtime()</a></i>,<i><a href="strftime.html">strftime()</a></i>,<i><a href="strptime.html">strptime()</a></i>,<i><a href="time.html">time()</a></i>,<i><a href="utime.html">utime()</a></i>,<i><a href="time.h.html"><time.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the POSIX.1-1988 standard and ANSI C standard.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?