From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/chrono%2Ftimespec_get.html | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 devdocs/c/chrono%2Ftimespec_get.html (limited to 'devdocs/c/chrono%2Ftimespec_get.html') diff --git a/devdocs/c/chrono%2Ftimespec_get.html b/devdocs/c/chrono%2Ftimespec_get.html new file mode 100644 index 00000000..ab32e7f2 --- /dev/null +++ b/devdocs/c/chrono%2Ftimespec_get.html @@ -0,0 +1,43 @@ +

timespec_get

Defined in header <time.h>
int timespec_get( struct timespec *ts, int base );
+
(1) (since C11)
#define TIME_UTC /* implementation-defined */
+
(2) (since C11)
+1) Modifies the timespec object pointed to by ts to hold the current calendar time in the time base base.
+2) Expands to a value suitable for use as the base argument of timespec_get +

Other macro constants beginning with TIME_ may be provided by the implementation to indicate additional time bases

+

If base is TIME_UTC, then

+

Parameters

+ + +
ts - pointer to an object of type struct timespec
base - TIME_UTC or another nonzero integer value indicating the time base

Return value

The value of base if successful, zero otherwise.

+

Notes

The POSIX function clock_gettime(CLOCK_REALTIME, ts) may also be used to populate a timespec with the time since the Epoch.

+

Example

#include <stdio.h>
+#include <time.h>
+ 
+int main(void)
+{
+    struct timespec ts;
+    timespec_get(&ts, TIME_UTC);
+    char buff[100];
+    strftime(buff, sizeof buff, "%D %T", gmtime(&ts.tv_sec));
+    printf("Current time: %s.%09ld UTC\n", buff, ts.tv_nsec);
+}

Possible output:

+
Current time: 02/18/15 14:34:03.048508855 UTC

References

See also

+ + + +
+
(C11)
time in seconds and nanoseconds
(struct)
+
(C23)
returns the resolution of calendar time based on a given time base
(function)
returns the current calendar time of the system as time since epoch
(function)
C++ documentation for timespec_get
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/chrono/timespec_get +

+
-- cgit v1.2.3