timespec_get

From cppreference.com
< c‎ | chrono
Defined in header <time.h>
int timespec_get( struct timespec *ts, int base)
(since C11)
#define TIME_UTC /* implementation-defined */
(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

  • ts->tv_sec is set to the number of seconds since an implementation defined epoch, truncated to a whole value
  • ts->tv_nsec member is set to the integral number of nanoseconds, rounded to the resolution of the system clock

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.