On this page
timespec_get
Prev: time | Up: time.h | Next: strftime
Rel: time.h, math, time & assert Guide
Ref: cppreference — timespec_get
Tags: #public #prog #c #stdlib #time #tier/standard
Include
#include <time.h>
Signature & Overview
int timespec_get(struct timespec *ts, int base);
Populates ts->tv_sec and ts->tv_nsec with nanosecond resolution (C11 TIME_UTC).
Notes & Pitfalls
- C11 nanosecond wall-clock timestamp (
TIME_UTC): Check return value== TIME_UTC.
Example
#include <assert.h>
#include <time.h>
int main(void) {
struct timespec ts;
assert(timespec_get(&ts, TIME_UTC) == TIME_UTC && ts.tv_sec > 0);
}
Linked from
Related notes
- tuts/c/stdlib/time/strftime Linked here; links to this page; shared tags: #c, #prog, #stdlib, #tier, #time
- tuts/c/stdlib/time/time Linked here; links to this page; shared tags: #c, #prog, #stdlib, #tier, #time
- tuts/c/stdlib/time Linked here; links to this page; shared tags: #c, #prog, #stdlib, #time
- tuts/c/stdlib/math_time_and_assert Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/time/asctime shared tags: #c, #prog, #stdlib, #tier, #time
- tuts/c/stdlib/time/gmtime shared tags: #c, #prog, #stdlib, #tier, #time
- tuts/c/stdlib/assert/assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/static_assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isalpha shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/isdigit shared tags: #c, #prog, #stdlib, #tier