Add JS_NewDateObject, JS_NewDateObjectMsec, JS_ObjectIsDate to the JSAPI. Bug 625870, r=jorendorff, a=shaver.
authorAndrew Paprocki <andrew@ishiboo.com>
Tue, 18 Jan 2011 16:11:03 -0600
changeset 61050 54a8ab97c4196cc95974405b3919415657904111
parent 61049 42a8233d986f7a58d024bfb92b37fd6e3792cbc8
child 61051 f2c9c558e51eed801c9908f0be97aac742c75839
push id18207
push usercleary@mozilla.com
push dateFri, 21 Jan 2011 05:02:09 +0000
treeherdermozilla-central@aa618e93942e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff, shaver
bugs625870
milestone2.0b10pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Add JS_NewDateObject, JS_NewDateObjectMsec, JS_ObjectIsDate to the JSAPI. Bug 625870, r=jorendorff, a=shaver.
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -5702,16 +5702,42 @@ JS_SetErrorReporter(JSContext *cx, JSErr
     older = cx->errorReporter;
     cx->errorReporter = er;
     return older;
 }
 
 /************************************************************************/
 
 /*
+ * 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.
  */
 JS_PUBLIC_API(JSObject *)
 JS_NewRegExpObject(JSContext *cx, JSObject *obj, char *bytes, size_t length, uintN flags)
 {
     CHECK_REQUEST(cx);
     jschar *chars = js_InflateString(cx, bytes, &length);
     if (!chars)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3592,16 +3592,34 @@ struct JSErrorReport {
                                               JSREPORT_STRICT_MODE_ERROR) != 0)
 
 extern JS_PUBLIC_API(JSErrorReporter)
 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.
  */
 #define JSREG_FOLD      0x01    /* fold uppercase to lowercase */
 #define JSREG_GLOB      0x02    /* global exec, creates array of matches */
 #define JSREG_MULTILINE 0x04    /* treat ^ and $ as begin and end of line */
 #define JSREG_STICKY    0x08    /* only match starting at lastIndex */
 #define JSREG_FLAT      0x10    /* parse as a flat regexp */
 #define JSREG_NOCOMPILE 0x20    /* do not try to compile to native code */