1 function psi\time() : int {
6 // extern int gettimeofday(struct timeval *tp, struct timezone *tz);
7 function psi\gettimeofday(array &$tv = NULL, array &$tz = NULL) : int {
8 let tp = calloc(1, psi\SIZEOF_STRUCT_TIMEVAL);
9 let tz = calloc(1, psi\SIZEOF_STRUCT_TIMEZONE);
10 return to_int(gettimeofday);
11 set $tv = to_array(*tp,
14 set $tz = to_array(*tz,
15 to_int(tz_minuteswest),
19 // extern char *asctime(struct tm *tm);
20 function psi\asctime(array $tm = NULL) : string {
21 let tm = &arrval($tm);
22 return to_string(asctime);
25 // extern char *asctime_r(struct tm *tm, char *buf);
26 function psi\asctime_r(array $tm = NULL) : string {
27 let tm = &arrval($tm);
28 let buf = calloc(32, psi\SIZEOF_CHAR);
29 return to_string(asctime_r);
32 // extern struct tm *gmtime(time_t *t);
33 function psi\gmtime(int $ts) : array {
35 return to_array(*gmtime,
48 // extern struct tm *gmtime_r(time_t *t, struct tm *buf);
49 function psi\gmtime_r(int $ts) : array {
51 let buf = calloc(1, psi\SIZEOF_STRUCT_TM);
52 return to_array(*gmtime_r,
65 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
66 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
67 let rqts = &arrval($rq);
68 let rmts = calloc(1, psi\SIZEOF_STRUCT_TIMESPEC);
69 return to_int(nanosleep);
70 set $rm = to_array(*rmts,
76 // extern clock_t times(struct tms *buf);
77 function psi\times(array &$tms = NULL) : int {
78 let buf = calloc(1, psi\SIZEOF_STRUCT_TMS);
80 set $tms = to_array(*buf,