Fix to 61183. Detect whether the OS has given us a date string ending in /xx (as in xx/xx/xx) for Date.prototype.toLocale[Date]String, and pad it out to the real number of digits.

r=rogerl
This commit is contained in:
mccabe%netscape.com 2000-11-30 05:52:44 +00:00
parent bdef0461a0
commit 51e20d88e5

View File

@ -1630,6 +1630,14 @@ date_toLocaleHelper(JSContext *cx, JSObject *obj, uintN argc,
/* If it failed, default to toString. */
if (result_len == 0)
return date_format(cx, *date, FORMATSPEC_FULL, rval);
/* Hacked check against undesired 2-digit year 00/00/00 form. */
if (buf[result_len - 3] == '/' &&
isdigit(buf[result_len - 2]) && isdigit(buf[result_len - 1])) {
JS_snprintf(buf + (result_len - 2), (sizeof buf) - (result_len - 2),
"%d", js_DateGetYear(cx, obj));
}
}
str = JS_NewStringCopyZ(cx, buf);