diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/chrono%2Ftime.html | |
new repository
Diffstat (limited to 'devdocs/c/chrono%2Ftime.html')
| -rw-r--r-- | devdocs/c/chrono%2Ftime.html | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/devdocs/c/chrono%2Ftime.html b/devdocs/c/chrono%2Ftime.html new file mode 100644 index 00000000..b7656af1 --- /dev/null +++ b/devdocs/c/chrono%2Ftime.html @@ -0,0 +1,40 @@ + <h1 id="firstHeading" class="firstHeading">time</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><time.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td class="t-dcl-nopad"> <pre data-language="c">time_t time( time_t *arg );</pre> +</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> </table> <p>Returns the current calendar time encoded as a <code><a href="time_t" title="c/chrono/time t">time_t</a></code> object, and also stores it in the <code><a href="time_t" title="c/chrono/time t">time_t</a></code> object pointed to by <code>arg</code> (unless <code>arg</code> is a null pointer)</p> +<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> arg </td> <td> - </td> <td> pointer to a <code><a href="time_t" title="c/chrono/time t">time_t</a></code> object where the time will be stored, or a null pointer </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <p>Current calendar time encoded as <code><a href="time_t" title="c/chrono/time t">time_t</a></code> object on success, <code><span class="br0">(</span><a href="http://en.cppreference.com/w/c/chrono/time_t"><span class="kw523">time_t</span></a><span class="br0">)</span><span class="br0">(</span><span class="sy2">-</span><span class="nu0">1</span><span class="br0">)</span></code> on error. If <code>arg</code> is not a null pointer, the return value is also stored in the object pointed to by <code>arg</code>.</p> +<h3 id="Notes"> Notes</h3> <p>The encoding of calendar time in <code><a href="time_t" title="c/chrono/time t">time_t</a></code> is unspecified, but most systems conform to <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/time.html">POSIX specification</a> and return a value of integral type holding the number of seconds since <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_15">the Epoch</a>. Implementations in which <code><a href="time_t" title="c/chrono/time t">time_t</a></code> is a 32-bit signed integer (many historical implementations) fail in the year <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Year_2038_problem">2038</a>.</p> +<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> +#include <time.h> +#include <stdint.h> + +int main(void) +{ + time_t result = time(NULL); + if(result != (time_t)(-1)) + printf("The current time is %s(%jd seconds since the Epoch)\n", + asctime(gmtime(&result)), (intmax_t)result); +}</pre></div> <p>Possible output:</p> +<div class="text source-text"><pre data-language="c">The current time is Fri Apr 24 15:05:25 2015 +(1429887925 seconds since the Epoch)</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C17 standard (ISO/IEC 9899:2018): </li> +<ul><li> 7.27.2.4 The time function (p: 286) </li></ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul><li> 7.27.2.4 The time function (p: 391) </li></ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul><li> 7.23.2.4 The time function (p: 341) </li></ul> +<li> C89/C90 standard (ISO/IEC 9899:1990): </li> +<ul><li> 4.12.2.4 The time function </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="localtime" title="c/chrono/localtime"> <span class="t-lines"><span>localtime</span><span>localtime_r</span><span>localtime_s</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> converts time since epoch to calendar time expressed as local time <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="gmtime" title="c/chrono/gmtime"> <span class="t-lines"><span>gmtime</span><span>gmtime_r</span><span>gmtime_s</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> converts time since epoch to calendar time expressed as Coordinated Universal Time (UTC) <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="timespec_get" title="c/chrono/timespec get"> <span class="t-lines"><span>timespec_get</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> returns the calendar time in seconds and nanoseconds based on a given time base <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/chrono/c/time" title="cpp/chrono/c/time">C++ documentation</a></span> for <code>time</code> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/chrono/time" class="_attribution-link">https://en.cppreference.com/w/c/chrono/time</a> + </p> +</div> |
