summaryrefslogtreecommitdiff
path: root/devdocs/c/chrono%2Ftimespec.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/chrono%2Ftimespec.html')
-rw-r--r--devdocs/c/chrono%2Ftimespec.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/devdocs/c/chrono%2Ftimespec.html b/devdocs/c/chrono%2Ftimespec.html
new file mode 100644
index 00000000..f799f3a3
--- /dev/null
+++ b/devdocs/c/chrono%2Ftimespec.html
@@ -0,0 +1,43 @@
+ <h1 id="firstHeading" class="firstHeading">timespec</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;time.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">struct timespec;</pre>
+</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <p>Structure holding an interval broken down into seconds and nanoseconds.</p>
+<h3 id="Member_objects"> Member objects</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <code><a href="time_t" title="c/chrono/time t">time_t</a></code> <code>tv_sec</code> </td> <td> whole seconds (valid values are &gt;= 0) </td>
+</tr> <tr class="t-dsc"> <td> <code>/* see below */</code> <code>tv_nsec</code> </td> <td> nanoseconds (valid values are [0, 999999999]) </td>
+</tr> </table> <table class="t-rev-begin"> <tr class="t-rev t-until-c23">
+<td> <p>The type of <code>tv_nsec</code> is <code>long</code>.</p>
+</td> <td><span class="t-mark-rev t-until-c23">(until C23)</span></td>
+</tr> <tr class="t-rev t-since-c23">
+<td> <p>The type of <code>tv_nsec</code> is an implementation-defined signed integer type that can represent integers in [0, 999999999].</p>
+</td> <td><span class="t-mark-rev t-since-c23">(since C23)</span></td>
+</tr> </table> <p>The declaration order of <code>tv_sec</code> and <code>tv_nsec</code> is unspecified. Implementation may add other members to <code>struct timespec</code>.</p>
+<h3 id="Notes"> Notes</h3> <p>The type of <code>tv_nsec</code> is <code>long long</code> on some platforms, which is conforming only since C23.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+#include &lt;time.h&gt;
+#include &lt;stdint.h&gt;
+
+int main(void)
+{
+ struct timespec ts;
+ timespec_get(&amp;ts, TIME_UTC);
+ char buff[100];
+ strftime(buff, sizeof buff, "%D %T", gmtime(&amp;ts.tv_sec));
+ printf("Current time: %s.%09ld UTC\n", buff, ts.tv_nsec);
+ printf("Raw timespec.time_t: %jd\n", (intmax_t)ts.tv_sec);
+ printf("Raw timespec.tv_nsec: %09ld\n", ts.tv_nsec);
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">Current time: 11/24/21 03:10:50.408191283 UTC
+Raw timespec.time_t: 1637723450
+Raw timespec.tv_nsec: 408191283</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul><li> 7.27.1/3 Components of time (p: 284) </li></ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.27.1/3 Components of time (p: 388) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <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> <div><a href="tm" title="c/chrono/tm"> <span class="t-lines"><span>tm</span></span></a></div> </td> <td> calendar time type<br><span class="t-mark">(struct)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/chrono/c/timespec" title="cpp/chrono/c/timespec">C++ documentation</a></span> for <code>timespec</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/chrono/timespec" class="_attribution-link">https://en.cppreference.com/w/c/chrono/timespec</a>
+ </p>
+</div>