1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-25 06:33:16 +00:00

Add os.time

This commit is contained in:
Calvin Rose 2018-09-11 21:33:50 -04:00
parent 725fd52357
commit bcb79ec9b2

View File

@ -224,6 +224,12 @@ static int clock_gettime(int x, struct timespec *spec) {
#define CLOCK_MONOTONIC 0
#endif
static int os_time(JanetArgs args) {
JANET_FIXARITY(args, 0);
double dtime = (double)(time(NULL));
JANET_RETURN_REAL(args, dtime);
}
static int os_clock(JanetArgs args) {
JANET_FIXARITY(args, 0);
struct timespec tv;
@ -275,6 +281,7 @@ static const JanetReg cfuns[] = {
{"os.exit", os_exit},
{"os.getenv", os_getenv},
{"os.setenv", os_setenv},
{"os.time", os_time},
{"os.clock", os_clock},
{"os.sleep", os_sleep},
{"os.cwd", os_cwd},