On this page
  1. timespec_get
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

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

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