Add an API entry point for building JS Date objects from millisecond values.
Patches courtesy Chris Houck. r=mccabe. git-svn-id: svn://10.0.0.236/trunk@52130 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
b3f1a34e11
commit
c568cf9bed
@ -1864,12 +1864,10 @@ js_InitDateClass(JSContext *cx, JSObject *obj)
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
js_NewDateObject(JSContext* cx, int year, int mon, int mday,
|
||||
int hour, int min, int sec)
|
||||
js_NewDateObjectMsec(JSContext *cx, jsdouble msec_time)
|
||||
{
|
||||
JSObject *obj;
|
||||
jsdouble *date;
|
||||
jsdouble msec_time;
|
||||
|
||||
obj = js_NewObject(cx, &date_class, NULL, NULL);
|
||||
if (!obj)
|
||||
@ -1881,8 +1879,19 @@ js_NewDateObject(JSContext* cx, int year, int mon, int mday,
|
||||
if (!date)
|
||||
return NULL;
|
||||
|
||||
*date = msec_time;
|
||||
return obj;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject *)
|
||||
js_NewDateObject(JSContext* cx, int year, int mon, int mday,
|
||||
int hour, int min, int sec)
|
||||
{
|
||||
JSObject *obj;
|
||||
jsdouble msec_time;
|
||||
|
||||
msec_time = date_msecFromDate(year, mon, mday, hour, min, sec, 0);
|
||||
*date = UTC(msec_time);
|
||||
obj = js_NewDateObjectMsec(cx, UTC(msec_time));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,9 @@ js_InitDateClass(JSContext *cx, JSObject *obj);
|
||||
/*
|
||||
* These functions provide a C interface to the date/time object
|
||||
*/
|
||||
extern JS_FRIEND_API(JSObject*)
|
||||
js_NewDateObjectMsec(JSContext* cx, jsdouble msec_time);
|
||||
|
||||
extern JS_FRIEND_API(JSObject*)
|
||||
js_NewDateObject(JSContext* cx, int year, int mon, int mday,
|
||||
int hour, int min, int sec);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user