Add API to build Date objects
This commit is contained in:
parent
0bbb78ce5e
commit
268cde8270
2 changed files with 11 additions and 0 deletions
|
@ -46868,6 +46868,15 @@ static const JSCFunctionListEntry js_date_proto_funcs[] = {
|
|||
JS_CFUNC_DEF("toJSON", 1, js_date_toJSON ),
|
||||
};
|
||||
|
||||
JSValue JS_NewDate(JSContext *ctx, double epoch_ms)
|
||||
{
|
||||
JSValue obj = js_create_from_ctor(ctx, JS_UNDEFINED, JS_CLASS_DATE);
|
||||
if (JS_IsException(obj))
|
||||
return JS_EXCEPTION;
|
||||
JS_SetObjectData(ctx, obj, JS_NewFloat64(ctx, time_clip(epoch_ms)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
void JS_AddIntrinsicDate(JSContext *ctx)
|
||||
{
|
||||
JSValueConst obj;
|
||||
|
|
|
@ -676,6 +676,8 @@ JS_BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, JS_BOOL val)
|
|||
JSValue JS_NewArray(JSContext *ctx);
|
||||
int JS_IsArray(JSContext *ctx, JSValueConst val);
|
||||
|
||||
JSValue JS_NewDate(JSContext *ctx, double epoch_ms);
|
||||
|
||||
JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj,
|
||||
JSAtom prop, JSValueConst receiver,
|
||||
JS_BOOL throw_ref_error);
|
||||
|
|
Loading…
Reference in a new issue