5 // extern time_t time(time_t *t);
6 function psi\time() : int {
8 return time(t) as to_int(time);
11 // extern int gettimeofday(struct timeval *tp, struct timezone *tz);
12 function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
13 let tp = calloc(1, sizeof(struct timeval));
14 let tz = calloc(1, sizeof(struct timezone));
15 return gettimeofday(tp, tz) as to_int(gettimeofday);
16 set $tv = to_array(*tp,
19 set $tz = to_array(*tz,
20 to_int(tz_minuteswest),
24 // extern char *asctime(struct tm *tm);
25 function psi\asctime(array $tm) : string {
37 return asctime(tm) as to_string(asctime);
40 // extern char *asctime_r(struct tm *tm, char *buf);
41 function psi\asctime_r(array $tm) : string {
53 let buf = calloc(32, sizeof(char));
54 return asctime_r(tm, buf) as to_string(asctime_r);
57 // extern struct tm *gmtime(time_t *t);
58 function psi\gmtime(int $ts) : array {
60 return gmtime(t) as to_array(*gmtime,
73 // extern struct tm *gmtime_r(time_t *t, struct tm *buf);
74 function psi\gmtime_r(int $ts) : array {
76 let buf = calloc(1, sizeof(struct tm));
77 return gmtime_r(t, buf) as to_array(*gmtime_r,
90 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
91 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
92 let rqts = &arrval($rq,
96 let rmts = calloc(1, sizeof(struct timespec));
97 return nanosleep(rqts, rmts) as to_int(nanosleep);
98 set $rm = to_array(*rmts,
105 // extern clock_t times(struct tms *buf);
106 function psi\times(array &$tms = NULL) : int {
107 let buf = calloc(1, sizeof(struct tms));
108 return times(buf) as to_int(times);
109 set $tms = to_array(*buf,