forked from ground/ground
12 lines
362 B
C
12 lines
362 B
C
|
|
#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);
|
||
|
|
}
|