From bcb79ec9b2c283803a278588ae99ae6f4d005753 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Tue, 11 Sep 2018 21:33:50 -0400 Subject: [PATCH] Add os.time --- src/core/os.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/os.c b/src/core/os.c index 24dc20ee..187790b3 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -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},