📄 time.h.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title><time.h></title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="<time.h>"></a> <a name="tag_13_76"></a><!-- <time.h> --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_13_76_01"></a>NAME</h4><blockquote>time.h - time types</blockquote><h4><a name="tag_13_76_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><tt>#include <time.h></tt></p></blockquote><h4><a name="tag_13_76_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> Some of the functionality described on this reference page extends the ISO C standard. Applications shall definethe appropriate feature test macro (see the System Interfaces volume of IEEE Std 1003.1-2001, <a href="../functions/xsh_chap02_02.html">Section 2.2, The Compilation Environment</a>) to enable the visibility of these symbols in thisheader. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>The <i><time.h></i> header shall declare the structure <b>tm</b>, which shall include at least the following members:</p><pre><tt>int tm_sec </tt> Seconds [0,60]. <tt>int tm_min </tt> Minutes [0,59]. <tt>int tm_hour </tt> Hour [0,23]. <tt>int tm_mday </tt> Day of month [1,31]. <tt>int tm_mon </tt> Month of year [0,11]. <tt>int tm_year </tt> Years since 1900. <tt>int tm_wday </tt> Day of week [0,6] (Sunday =0). <tt>int tm_yday </tt> Day of year [0,365]. <tt>int tm_isdst</tt> Daylight Savings flag. <tt></tt></pre><p>The value of <i>tm_isdst</i> shall be positive if Daylight Savings Time is in effect, 0 if Daylight Savings Time is not ineffect, and negative if the information is not available.</p><p>The <i><time.h></i> header shall define the following symbolic names:</p><dl compact><dt>NULL</dt><dd>Null pointer constant.</dd><dt>CLOCKS_PER_SEC</dt><dd>A number used to convert the value returned by the <a href="../functions/clock.html"><i>clock</i>()</a> function intoseconds.</dd><dt>CLOCK_PROCESS_CPUTIME_ID</dt><dd><sup>[<a href="javascript:open_code('TMR')">TMR|CPT</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>The identifier of the CPU-time clock associated with the process making a <a href="../functions/clock.html"><i>clock</i>()</a> or<a href="../functions/timer_create.html"><i>timer*</i>()</a> function call. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>CLOCK_THREAD_CPUTIME_ID</dt><dd><sup>[<a href="javascript:open_code('TMR')">TMR|TCT</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>The identifier of the CPU-time clock associated with the thread making a <a href="../functions/clock.html"><i>clock</i>()</a> or <ahref="../functions/timer_create.html"><i>timer*</i>()</a> function call. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p><sup>[<a href="javascript:open_code('TMR')">TMR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i><time.h></i> header shall declare the structure <b>timespec</b>, which has at least the following members:</p><pre><tt>time_t tv_sec </tt> Seconds. <tt>long tv_nsec </tt> Nanoseconds. <tt></tt></pre><p>The <i><time.h></i> header shall also declare the <b>itimerspec</b> structure, which has at least the followingmembers:</p><pre><tt>struct timespec it_interval </tt> Timer period. <tt>struct timespec it_value </tt> Timer expiration. <tt></tt></pre><p>The following manifest constants shall be defined:</p><dl compact><dt>CLOCK_REALTIME</dt><dd>The identifier of the system-wide realtime clock.</dd><dt>TIMER_ABSTIME</dt><dd>Flag indicating time is absolute. For functions taking timer objects, this refers to the clock associated with the timer. <imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>CLOCK_MONOTONIC</dt><dd><sup>[<a href="javascript:open_code('MON')">MON</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>The identifier for the system-wide monotonic clock, which is defined as a clock whose value cannot be set via <a href="../functions/clock_settime.html"><i>clock_settime</i>()</a> and which cannot have backward clock jumps. The maximum possible clockjump shall be implementation-defined. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>The <b>clock_t</b>, <b>size_t</b>, <b>time_t</b>, <sup>[<a href="javascript:open_code('TMR')">TMR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> <b>clockid_t</b>, and <b>timer_t</b> <img src="../images/opt-end.gif"alt="[Option End]" border="0"> types shall be defined as described in <a href="sys/types.h.html"><i><sys/types.h></i></a>.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Although the value of CLOCKS_PER_SEC is required to be 1 million on all XSI-conformant systems, it may be variable on othersystems, and it should not be assumed that CLOCKS_PER_SEC is a compile-time constant. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i><time.h></i> header shall provide a declaration for <i>getdate_err</i>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.</p><pre><tt>char *asctime(const struct tm *);<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">char *asctime_r(const struct tm *restrict, char *restrict);<img src="../images/opt-end.gif" alt="[Option End]" border="0">clock_t clock(void);<sup>[<a href="javascript:open_code('CPT')">CPT</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int clock_getcpuclockid(pid_t, clockid_t *);<img src="../images/opt-end.gif" alt="[Option End]" border="0"><sup>[<a href="javascript:open_code('TMR')">TMR</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int clock_getres(clockid_t, struct timespec *);int clock_gettime(clockid_t, struct timespec *);<img src="../images/opt-end.gif" alt="[Option End]" border="0"><sup>[<a href="javascript:open_code('CS')">CS</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);<img src="../images/opt-end.gif" alt="[Option End]" border="0"><sup>[<a href="javascript:open_code('TMR')">TMR</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int clock_settime(clockid_t, const struct timespec *);<img src="../images/opt-end.gif" alt="[Option End]" border="0">char *ctime(const time_t *);<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">char *ctime_r(const time_t *, char *);<img src="../images/opt-end.gif" alt="[Option End]" border="0">double difftime(time_t, time_t);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">struct tm *getdate(const char *);<img src="../images/opt-end.gif" alt="[Option End]" border="0">struct tm *gmtime(const time_t *);<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -