if (format == FORMATSPEC_FULL) {
switch (format) { case FORMATSPEC_FULL:
date_format(JSContext *cx, jsdouble date, formatspec format, jsval *rval){    char buf[100];    JSString *str;    char tzbuf[100];    JSBool usetz;    size_t i, tzlen;    PRMJTime split;    if (!JSDOUBLE_IS_FINITE(date)) {	JS_snprintf(buf, sizeof buf, js_NaN_date_str);    } else {	jsdouble local = LocalTime(date);	/* offset from GMT in minutes.  The offset includes daylight savings,	   if it applies. */	jsint minutes = (jsint) floor((LocalTZA + DaylightSavingTA(date))				      / msPerMinute);	/* map 510 minutes to 0830 hours */	intN offset = (minutes / 60) * 100 + minutes % 60;	/* print as "Wed Nov 05 19:38:03 GMT-0800 (PST) 1997" The TZA is	 * printed as 'GMT-0800' rather than as 'PST' to avoid	 * operating-system dependence on strftime (which	 * PRMJ_FormatTimeUSEnglish calls, for %Z only.)  win32 prints	 * PST as 'Pacific Standard Time.'  This way we always know	 * what we're getting, and can parse it if we produce it.	 * The OS TZA string is included as a comment.	 */	/* get a timezone string from the OS to include as a	   comment. */	new_explode(date, &split, JS_TRUE);	PRMJ_FormatTime(tzbuf, sizeof tzbuf, "(%Z)", &split);        /* Decide whether to use the resulting timezone string.         *         * Reject it if it contains any non-ASCII, non-alphanumeric characters.         * It's then likely in some other character encoding, and we probably         * won't display it correctly.         */        usetz = JS_TRUE;        tzlen = strlen(tzbuf);        if (tzlen > 100) {            usetz = JS_FALSE;        } else {            for (i = 0; i < tzlen; i++) {                jschar c = tzbuf[i];                if (c > 127 || !(isalpha(c) || isdigit(c) ||                      c == ' ' || c == '(' || c == ')'))                    usetz = JS_FALSE;            }        }                /* Also reject it if it's not parenthesized or if it's '()'. */        if (tzbuf[0] != '(' || tzbuf[1] == ')')            usetz = JS_FALSE;        if (format == FORMATSPEC_FULL) {            /*             * Avoid dependence on PRMJ_FormatTimeUSEnglish, because it             * requires a PRMJTime... which only has 16-bit years.  Sub-ECMA.             */            /* Tue Oct 31 09:41:40 GMT-0800 (PST) 2000 */            JS_snprintf(buf, sizeof buf,                        "%s %s %.2d %.2d:%.2d:%.2d GMT%+.4d %s%s%.4d",                        days[WeekDay(local)],                        months[MonthFromTime(local)],                        DateFromTime(local),                        HourFromTime(local),                        MinFromTime(local),                        SecFromTime(local),                        offset,                        usetz ? tzbuf : "",                        usetz ? " " : "",                        YearFromTime(local));        } else if (format == FORMATSPEC_DATE) {            /* Tue Oct 31 2000 */            JS_snprintf(buf, sizeof buf,                        "%s %s %.2d %.4d",                        days[WeekDay(local)],                        months[MonthFromTime(local)],                        DateFromTime(local),                        YearFromTime(local));        } else if (format == FORMATSPEC_TIME) {            /* 09:41:40 GMT-0800 (PST) */            JS_snprintf(buf, sizeof buf,                        "%.2d:%.2d:%.2d GMT%+.4d%s%s",                        HourFromTime(local),                        MinFromTime(local),                        SecFromTime(local),                        offset,                        usetz ? " " : "",                        usetz ? tzbuf : "");        } else {            return JS_FALSE;        }    }    str = JS_NewStringCopyZ(cx, buf);    if (!str)	return JS_FALSE;    *rval = STRING_TO_JSVAL(str);    return JS_TRUE;}