added os.now()

This commit is contained in:
Fabrice Bellard
2023-12-27 19:09:29 +01:00
parent ffe81419ff
commit 2ee6be705f
4 changed files with 32 additions and 44 deletions

View File

@@ -42791,30 +42791,6 @@ static const JSCFunctionListEntry js_math_obj[] = {
/* Date */
#if 0
/* OS dependent: return the UTC time in ms since 1970. */
static JSValue js___date_now(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
int64_t d;
struct timeval tv;
gettimeofday(&tv, NULL);
d = (int64_t)tv.tv_sec * 1000 + (tv.tv_usec / 1000);
return JS_NewInt64(ctx, d);
}
#endif
/* OS dependent: return the UTC time in microseconds since 1970. */
static JSValue js___date_clock(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
int64_t d;
struct timeval tv;
gettimeofday(&tv, NULL);
d = (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
return JS_NewInt64(ctx, d);
}
/* OS dependent. d = argv[0] is in ms from 1970. Return the difference
between UTC time and local time 'd' in minutes */
static int getTimezoneOffset(int64_t time) {
@@ -48899,12 +48875,6 @@ static const JSCFunctionListEntry js_global_funcs[] = {
JS_PROP_DOUBLE_DEF("Infinity", 1.0 / 0.0, 0 ),
JS_PROP_DOUBLE_DEF("NaN", NAN, 0 ),
JS_PROP_UNDEFINED_DEF("undefined", 0 ),
/* for the 'Date' implementation */
JS_CFUNC_DEF("__date_clock", 0, js___date_clock ),
//JS_CFUNC_DEF("__date_now", 0, js___date_now ),
//JS_CFUNC_DEF("__date_getTimezoneOffset", 1, js___date_getTimezoneOffset ),
//JS_CFUNC_DEF("__date_create", 3, js___date_create ),
};
/* Date */