From f73f9bb25a2fb2739fc692cf0a8d017d7868df0d Mon Sep 17 00:00:00 2001 From: Andrew Paprocki Date: Tue, 18 Jan 2011 16:11:03 -0600 Subject: [PATCH] Add JS_NewDateObject, JS_NewDateObjectMsec, JS_ObjectIsDate to the JSAPI. Bug 625870, r=jorendorff, a=shaver. --- js/src/jsapi.cpp | 26 ++++++++++++++++++++++++++ js/src/jsapi.h | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 36f702b827a9..21662fc81b82 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -5706,6 +5706,32 @@ JS_SetErrorReporter(JSContext *cx, JSErrorReporter er) /************************************************************************/ +/* + * Dates. + */ +JS_PUBLIC_API(JSObject *) +JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec) +{ + CHECK_REQUEST(cx); + return js_NewDateObject(cx, year, mon, mday, hour, min, sec); +} + +JS_PUBLIC_API(JSObject *) +JS_NewDateObjectMsec(JSContext *cx, jsdouble msec) +{ + CHECK_REQUEST(cx); + return js_NewDateObjectMsec(cx, msec); +} + +JS_PUBLIC_API(JSBool) +JS_ObjectIsDate(JSContext *cx, JSObject *obj) +{ + JS_ASSERT(obj); + return obj->isDate(); +} + +/************************************************************************/ + /* * Regular Expressions. */ diff --git a/js/src/jsapi.h b/js/src/jsapi.h index e07eb4268bec..5e3984f07d43 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3596,6 +3596,24 @@ JS_SetErrorReporter(JSContext *cx, JSErrorReporter er); /************************************************************************/ +/* + * Dates. + */ + +extern JS_PUBLIC_API(JSObject *) +JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); + +extern JS_PUBLIC_API(JSObject *) +JS_NewDateObjectMsec(JSContext *cx, jsdouble msec); + +/* + * Infallible predicate to test whether obj is a date object. + */ +extern JS_PUBLIC_API(JSBool) +JS_ObjectIsDate(JSContext *cx, JSObject *obj); + +/************************************************************************/ + /* * Regular Expressions. */