CKTIS / C
dates and time — concept C23
C distinguishes calendar `time_t`, processor `clock_t`, and `timespec`; conversions can fail, while time zone, daylight changes, and resolution depend on the environment.
Version: C23
Syntax
dates and timeC distinguishes calendar time_t, processor clock_t, and timespec; conversions can fail, while time zone, daylight changes, and resolution depend on the environment.
For elapsed time, choose a monotonic clock supplied by the platform; time and TIME_UTC represent calendar time and can jump after clock correction. For human formatting, convert time_t with checked functions and select time zone and locale explicitly.
Check conversion failure, dates before the epoch, daylight-saving transitions, leap seconds, and target-type overflow. Functions returning a pointer to static storage may be overwritten by the next call and need protection in concurrent code.
Examples
#include <stdio.h>
#include <time.h>
int main(void) { struct timespec value; int base = timespec_get(&value, TIME_UTC); printf("%d\n", base == TIME_UTC); return 0; }
Result
1
C distinguishes calendar `time_t`, processor `clock_t`, and `timespec`; conversions can fail, while time zone, daylight changes, and resolution depend on the environment.