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 = NULL) : string {
22 let tm = &arrval($tm);
23 return to_string(asctime);
26 // extern char *asctime_r(struct tm *tm, char *buf);
27 function psi\asctime_r(array $tm = NULL) : string {
28 let tm = &arrval($tm);
29 let buf = calloc(32, psi\SIZEOF_CHAR);
30 return to_string(asctime_r);
33 // extern struct tm *gmtime(time_t *t);
34 function psi\gmtime(int $ts) : array {
36 return to_array(*gmtime,
49 // extern struct tm *gmtime_r(time_t *t, struct tm *buf);
50 function psi\gmtime_r(int $ts) : array {
52 let buf = calloc(1, psi\SIZEOF_STRUCT_TM);
53 return to_array(*gmtime_r,
66 // extern int nanosleep(struct timespec *rqts, struct timespec *rmts);
67 function psi\nanosleep(array $rq = NULL, array &$rm = NULL) : int {
68 let rqts = &arrval($rq);
69 let rmts = calloc(1, psi\SIZEOF_STRUCT_TIMESPEC);
70 return to_int(nanosleep);
71 set $rm = to_array(*rmts,
77 // extern clock_t times(struct tms *buf);
78 function psi\times(array &$tms = NULL) : int {
79 let buf = calloc(1, psi\SIZEOF_STRUCT_TMS);
81 set $tms = to_array(*buf,