Skip to content

Commit

Permalink
Add JS_IsDate function
Browse files Browse the repository at this point in the history
  • Loading branch information
ABBAPOH committed Jan 8, 2025
1 parent 291eb9c commit fe43f68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -51266,6 +51266,13 @@ JSValue JS_NewDate(JSContext *ctx, double epoch_ms)
return obj;
}

JS_BOOL JS_IsDate(JSValue v)
{
if (JS_VALUE_GET_TAG(v) != JS_TAG_OBJECT)
return FALSE;
return JS_VALUE_GET_OBJ(v)->class_id == JS_CLASS_DATE;
}

void JS_AddIntrinsicDate(JSContext *ctx)
{
JSValue obj;
Expand Down
1 change: 1 addition & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ JS_EXTERN JSValue JS_NewArray(JSContext *ctx);
JS_EXTERN int JS_IsArray(JSContext *ctx, JSValue val);

JS_EXTERN JSValue JS_NewDate(JSContext *ctx, double epoch_ms);
JS_EXTERN JS_BOOL JS_IsDate(JSValue v);

JS_EXTERN JSValue JS_GetProperty(JSContext *ctx, JSValue this_obj, JSAtom prop);
JS_EXTERN JSValue JS_GetPropertyUint32(JSContext *ctx, JSValue this_obj,
Expand Down

0 comments on commit fe43f68

Please sign in to comment.