struct timespec represents a time value by combining whole seconds with a nanosecond component. It uses the opaque time_t type for seconds and long for nanoseconds, preserving more precision than time_t alone. section 6.3.2 section 8.6
struct timespec {
time_t tv_sec; // Whole seconds ≥ 0
long tv_nsec; // Nanoseconds [0, 999999999]
};
The declaration makes the representation and stated value ranges explicit: tv_sec stores whole seconds, while tv_nsec stores nanoseconds from 0 through 999999999. section 6.3.2
Use timespec_get to obtain a struct timespec value. The required TIME_UTC base is expected to agree with time; timespec_getres, added in C23, can query clock resolution. A difference operation between two struct timespec values can be implemented without platform-specific properties. section 6.3.2 section 8.6
TAKEAWAY:
- Choose struct timespec when second-level time_t precision is insufficient. section 8.6
- Treat tv_sec and tv_nsec as distinct components of one time value. section 6.3.2

