Module libc/time

libc/time
Stability: unstable — a raw C binding, not a Yo design. `std/time` is the public surface (`Instant`, `Duration`, `DateTime`); what it takes from here is `localtime_r` for `DateTime`'s local-time conversion. The bindings are deliberately shaped around a portability trap this module cannot fix: `tm` is opaque so `localtime_r` is typed through `*void`, and MSVC has no `localtime_r` at all while its `localtime_s` REVERSES the C11 Annex K argument order — so the Annex K binding here must not be called on Windows, where `std/libc/windows`'s `_localtime64_s` is the equivalent. Freezing would require one portable spelling of broken-down time, which C does not offer; use `std/time`. — stable modules only change additively; this one may still change.

C11 <time.h> — date and time functions.

Stability

unstable — a raw C binding, not a Yo design. std/time is the public surface (Instant, Duration, DateTime); what it takes from here is localtime_r for DateTime's local-time conversion. The bindings are deliberately shaped around a portability trap this module cannot fix: tm is opaque so localtime_r is typed through *void, and MSVC has no localtime_r at all while its localtime_s REVERSES the C11 Annex K argument order — so the Annex K binding here must not be called on Windows, where std/libc/windows's _localtime64_s is the equivalent. Freezing would require one portable spelling of broken-down time, which C does not offer; use std/time.

Types

time_t type-alias
time_t
clock_t type-alias
clock_t
tm type-alias
tm
timespec type-alias
timespec

Functions

clock function
fn() -> clock_t

Returns: clock_t

time function
fn(timer : ?(*(time_t))) -> time_t

Parameters

NameTypeNotes
timer?(*(time_t))

Returns: time_t

difftime function
fn(time1 : time_t, time0 : time_t) -> f64

Parameters

NameTypeNotes
time1time_t
time0time_t

Returns: f64

mktime function
fn(timeptr : *(tm)) -> time_t

Parameters

NameTypeNotes
timeptr*(tm)

Returns: time_t

asctime function
fn(timeptr : *(tm)) -> *(char)

Parameters

NameTypeNotes
timeptr*(tm)

Returns: *(char)

ctime function
fn(timer : *(time_t)) -> *(char)

Parameters

NameTypeNotes
timer*(time_t)

Returns: *(char)

gmtime function
fn(timer : *(time_t)) -> ?(*(tm))

Parameters

NameTypeNotes
timer*(time_t)

Returns: ?(*(tm))

localtime function
fn(timer : *(time_t)) -> ?(*(tm))

Parameters

NameTypeNotes
timer*(time_t)

Returns: ?(*(tm))

localtime_r function
fn(timer : *(void), result : *(void)) -> ?(*(void))

Parameters

NameTypeNotes
timer*(void)
result*(void)

Returns: ?(*(void))

strftime function
fn(s : *(char), maxsize : usize, format : *(char), timeptr : *(tm)) -> usize

Parameters

NameTypeNotes
s*(char)
maxsizeusize
format*(char)
timeptr*(tm)

Returns: usize

asctime_s function
fn(s : *(char), maxsize : usize, timeptr : *(tm)) -> int

Parameters

NameTypeNotes
s*(char)
maxsizeusize
timeptr*(tm)

Returns: int

ctime_s function
fn(s : *(char), maxsize : usize, timer : *(time_t)) -> int

Parameters

NameTypeNotes
s*(char)
maxsizeusize
timer*(time_t)

Returns: int

gmtime_s function
fn(timer : *(time_t), result : *(tm)) -> ?(*(tm))

Parameters

NameTypeNotes
timer*(time_t)
result*(tm)

Returns: ?(*(tm))

localtime_s function
fn(timer : *(time_t), result : *(tm)) -> ?(*(tm))

Parameters

NameTypeNotes
timer*(time_t)
result*(tm)

Returns: ?(*(tm))

timespec_get function
fn(ts : *(timespec), base : int) -> int

Parameters

NameTypeNotes
ts*(timespec)
baseint

Returns: int

Constants

CLOCKS_PER_SEC constant clock_t

Value: <unknown: clock_t>

TIME_UTC constant int

Value: <unknown: int>

CLK_TCK constant clock_t

Value: <unknown: clock_t>