3 // extern time_t time(time_t *t);
4 function psi\time() : int {
6 return time(t) as to_int(time);
9 // extern int gettimeofday(struct timeval *tp, struct timezone *tz);
10 function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
11 let tp = calloc(1, psi\SIZEOF_STRUCT_TIMEVAL);
12 let tz = calloc(1, psi\SIZEOF_STRUCT_TIMEZONE);
13 return gettimeofday(tp, tz) as to_int(gettimeofday);
14 set $tv = to_array(*tp,
17 set $tz = to_array(*tz,
18 to_int(tz_minuteswest),
22 // extern char *asctime(struct tm *tm);
23 function psi\asctime(array $tm) : string {
35 return asctime(tm) as to_string(asctime);
38 // extern char *asctime_r(struct tm *tm, char *buf);
39 function psi\asctime_r(array $tm) : string {
51 let buf = calloc(32, psi\SIZEOF_CHAR);
52 return asctime_r(tm, buf) as to_string(asctime_r);
55 // extern struct tm *gmtime(time_t *t);
56 function psi\gmtime(int $ts) : array {
58 return gmtime(t) as to_array(*gmtime,
71 // extern struct tm *gmtime_r(time_t *t, struct tm *buf);
72 function psi\gmtime_r(int $ts) : array {
74 let buf = calloc(1, psi\SIZEOF_STRUCT_TM);
75 return gmtime_r(t, buf) as to_array(*gmtime_r,
88 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
89 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
90 let rqts = &arrval($rq,
94 let rmts = calloc(1, psi\SIZEOF_STRUCT_TIMESPEC);
95 return nanosleep(rqts, rmts) as to_int(nanosleep);
96 set $rm = to_array(*rmts,
102 // extern clock_t times(struct tms *buf);
103 function psi\times(array &$tms = NULL) : int {
104 let buf = calloc(1, psi\SIZEOF_STRUCT_TMS);
105 return times(buf) as to_int(times);
106 set $tms = to_array(*buf,