first version of datetime lib

This commit is contained in:
2026-03-20 06:28:55 +11:00
parent e73fdddb4c
commit ccc8a61f66
5 changed files with 475 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
#include "time_functions.h"
GroundValue datetime_NowEpoch(GroundScope* scope, List args) {
// grab time from system clock
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
// convert it to secs and return it
double secsSinceEpoch = (double)ts.tv_sec + (double)ts.tv_nsec / 1e9;
return groundCreateValue(DOUBLE, secsSinceEpoch);
}