diff options
Diffstat (limited to 'devdocs/c/chrono%2Fdifftime.html')
| -rw-r--r-- | devdocs/c/chrono%2Fdifftime.html | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/devdocs/c/chrono%2Fdifftime.html b/devdocs/c/chrono%2Fdifftime.html deleted file mode 100644 index d72402bb..00000000 --- a/devdocs/c/chrono%2Fdifftime.html +++ /dev/null @@ -1,45 +0,0 @@ - <h1 id="firstHeading" class="firstHeading">difftime</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">double difftime( time_t time_end, time_t time_beg );</pre> -</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> </table> <p>Computes difference between two calendar times as <code><a href="time_t" title="c/chrono/time t">time_t</a></code> objects (<code>time_end - time_beg</code>) in seconds. If <code>time_end</code> refers to time point before <code>time_beg</code> then the result is negative.</p> -<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> time_beg, time_end </td> <td> - </td> <td> times to compare </td> -</tr> -</table> <h3 id="Return_value"> Return value</h3> <p>Difference between two times in seconds.</p> -<h3 id="Notes"> Notes</h3> <p>On POSIX systems, <code><a href="time_t" title="c/chrono/time t">time_t</a></code> is measured in seconds, and <code>difftime</code> is equivalent to arithmetic subtraction, but C and C++ allow fractional units for <code><a href="time_t" title="c/chrono/time t">time_t</a></code>.</p> -<h3 id="Example"> Example</h3> <div class="t-example"> -<p>The following program computes the number of seconds that have passed since the beginning of the month.</p> -<div class="c source-c"><pre data-language="c">#include <stdio.h> -#include <time.h> - -int main(void) -{ - time_t now = time(0); - - struct tm beg = *localtime(&now); - - // set beg to the beginning of the month - beg.tm_hour = 0, - beg.tm_min = 0, - beg.tm_sec = 0, - beg.tm_mday = 1; - - double seconds = difftime(now, mktime(&beg)); - - printf("%.f seconds have passed since the beginning of the month.\n", seconds); - - return 0; -}</pre></div> <p>Output:</p> -<div class="text source-text"><pre data-language="c">1937968 seconds have passed since the beginning of the month.</pre></div> </div> <h3 id="References"> References</h3> <ul> -<li> C17 standard (ISO/IEC 9899:2018): </li> -<ul><li> 7.27.2.2 The difftime function (p: 285) </li></ul> -<li> C11 standard (ISO/IEC 9899:2011): </li> -<ul><li> 7.27.2.2 The difftime function (p: 390) </li></ul> -<li> C99 standard (ISO/IEC 9899:1999): </li> -<ul><li> 7.23.2.2 The difftime function (p: 338) </li></ul> -<li> C89/C90 standard (ISO/IEC 9899:1990): </li> -<ul><li> 7.12.2.2 The difftime function (p: 171) </li></ul> -</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/chrono/c/difftime" title="cpp/chrono/c/difftime">C++ documentation</a></span> for <code>difftime</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/difftime" class="_attribution-link">https://en.cppreference.com/w/c/chrono/difftime</a> - </p> -</div> |
