1 // extern time_t time(time_t *t);
2 function psi\time() : int {
7 // extern int gettimeofday(struct timeval *tp, struct timezone *tz);
8 function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
9 let tp = calloc(1, psi\SIZEOF_STRUCT_TIMEVAL);
10 let tz = calloc(1, psi\SIZEOF_STRUCT_TIMEZONE);
11 return to_int(gettimeofday);
12 set $tv = to_array(*tp,
15 set $tz = to_array(*tz,
16 to_int(tz_minuteswest),
20 // extern char *asctime(struct tm *tm);
21 function psi\asctime(array $tm) : string {
33 return to_string(asctime);
36 // extern char *asctime_r(struct tm *tm, char *buf);
37 function psi\asctime_r(array $tm) : string {
49 let buf = calloc(32, psi\SIZEOF_CHAR);
50 return to_string(asctime_r);
53 // extern struct tm *gmtime(time_t *t);
54 function psi\gmtime(int $ts) : array {
56 return to_array(*gmtime,
69 // extern struct tm *gmtime_r(time_t *t, struct tm *buf);
70 function psi\gmtime_r(int $ts) : array {
72 let buf = calloc(1, psi\SIZEOF_STRUCT_TM);
73 return to_array(*gmtime_r,
86 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
87 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
88 let rqts = &arrval($rq,
92 let rmts = calloc(1, psi\SIZEOF_STRUCT_TIMESPEC);
93 return to_int(nanosleep);
94 set $rm = to_array(*rmts,
100 // extern clock_t times(struct tms *buf);
101 function psi\times(array &$tms = NULL) : int {
102 let buf = calloc(1, psi\SIZEOF_STRUCT_TMS);
103 return to_int(times);
104 set $tms = to_array(*buf,