NPOTB assertion for Date's 'friend' API, plus comments (410647, r=bclary).

This commit is contained in:
brendan@mozilla.org 2008-01-03 18:23:55 -08:00
Родитель f8b25558e4
Коммит 5c6db7edb0
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -2163,6 +2163,7 @@ js_NewDateObject(JSContext* cx, int year, int mon, int mday,
JSObject *obj;
jsdouble msec_time;
JS_ASSERT(mon < 12);
msec_time = date_msecFromDate(year, mon, mday, hour, min, sec, 0);
obj = js_NewDateObjectMsec(cx, UTC(msec_time));
return obj;
@ -2271,6 +2272,8 @@ js_DateSetMonth(JSContext *cx, JSObject *obj, int month)
{
jsdouble local;
JS_ASSERT(month < 12);
if (!GetLocalTime(cx, obj, NULL, &local))
return;

Просмотреть файл

@ -64,6 +64,10 @@ js_NewDateObjectMsec(JSContext* cx, jsdouble msec_time);
/*
* Construct a new Date Object from an exploded local time value.
*
* Assert that mon < 12 to help catch off-by-one user errors, which are common
* due to the 0-based month numbering copied into JS from Java (java.util.Date
* in 1995). js_DateSetMonth (below) likewise asserts month < 12.
*/
extern JS_FRIEND_API(JSObject*)
js_NewDateObject(JSContext* cx, int year, int mon, int mday,
@ -98,7 +102,7 @@ extern JS_FRIEND_API(void)
js_DateSetYear(JSContext *cx, JSObject *obj, int year);
extern JS_FRIEND_API(void)
js_DateSetMonth(JSContext *cx, JSObject *obj, int year);
js_DateSetMonth(JSContext *cx, JSObject *obj, int month);
extern JS_FRIEND_API(void)
js_DateSetDate(JSContext *cx, JSObject *obj, int date);