timespec_get(3)

timespec_get3

Get current calendar time

Usage

#include <time.h>

int

timespec_get(struct timespec *ts, int base);

Library

Standard C Library (libc, -lc)

Overview

The timespec_get function sets the interval pointed to by ts to hold the current calendar time based on the specified time base in base.

The base TIME_UTC returns the time since the epoch. This time is expressed in seconds and nanoseconds since midnight (0 hour), January 1, 1970. This corresponds to CLOCK_REALTIME.

Return values

The timespec_get function returns the passed value of base if successful, otherwise 0 on failure.

Releases

Unchanged in 45 releases since macOS 10.15.

  1. 10.15–26.5

Standards

The timespec_get function with a base of TIME_UTC conforms to ISO/IEC 9899:2011 (“ISO C11”).

Authors

Kamil Rytarowski ⟨[email protected]⟩ Warner Losh ⟨[email protected]⟩

From Libc 1752.120.2 in macOS 26.5. Parsed by carta from the page's mdoc source.