std1.0.0-beta-7 SafeC docs

Module time

#include <std/time.h> source

Time (comprehensive C11 <time.h>) Complements sys.h (which covers high-resolution clocks).

Structs

TimeFieldsBroken-down calendar time (C's struct tm fields, in the same order).

Functions

time_now
time_gmtimeA Unix timestamp as broken-down UTC time.
time_localtimeA Unix timestamp as broken-down local time.
time_formatFormats tm into buf with a strftime format string. Returns the number of bytes written (0 on failure or when buf is too small).
time_parseParses a time string with strptime (POSIX) into *tm. Returns 1 on success, 0 on failure (and on Windows).
time_mktimeConverts broken-down local time back to a Unix timestamp (-1 on error).
time_diffDifference in seconds between two timestamps.
time_wall_nsWall-clock time in nanoseconds (CLOCK_REALTIME).
time_mono_nsMonotonic clock in nanoseconds (CLOCK_MONOTONIC) — for elapsed time.
time_cpu_nsProcess CPU time in nanoseconds (CLOCK_PROCESS_CPUTIME_ID).
time_elapsed_nsElapsed nanoseconds between two mono timestamps.
time_ns_to_msConvert nanoseconds to milliseconds.
time_sleep_nsSleep for nanoseconds (high precision).
time_days_in_monthDays in a given month (month 0-11, year = actual year e.g. 2024).
time_is_leapReturn 1 if year is a leap year, 0 otherwise.