mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 291494: add Date.prototype.toLocaleFormat for better control over
localized Date formatting, as well as access to things like week-number and Julian dates. r+a=brendan.
This commit is contained in:
parent
a0b2d8a8ce
commit
eb77f9dcb6
@ -1703,6 +1703,23 @@ date_toLocaleTimeString(JSContext *cx, JSObject *obj, uintN argc,
|
||||
return date_toLocaleHelper(cx, obj, argc, argv, rval, "%X");
|
||||
}
|
||||
|
||||
static JSBool
|
||||
date_toLocaleFormat(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
JSString *fmt;
|
||||
|
||||
if (argc == 0)
|
||||
return date_toLocaleString(cx, obj, argc, argv, rval);
|
||||
|
||||
fmt = JS_ValueToString(cx, argv[0]);
|
||||
if (!fmt)
|
||||
return JS_FALSE;
|
||||
|
||||
return date_toLocaleHelper(cx, obj, argc, argv, rval,
|
||||
JS_GetStringBytes(fmt));
|
||||
}
|
||||
|
||||
static JSBool
|
||||
date_toTimeString(JSContext *cx, JSObject *obj, uintN argc,
|
||||
jsval *argv, jsval *rval)
|
||||
@ -1854,6 +1871,7 @@ static JSFunctionSpec date_methods[] = {
|
||||
{js_toLocaleString_str, date_toLocaleString, 0,0,0 },
|
||||
{"toLocaleDateString", date_toLocaleDateString,0,0,0 },
|
||||
{"toLocaleTimeString", date_toLocaleTimeString,0,0,0 },
|
||||
{"toLocaleFormat", date_toLocaleFormat, 1,0,0 },
|
||||
{"toDateString", date_toDateString, 0,0,0 },
|
||||
{"toTimeString", date_toTimeString, 0,0,0 },
|
||||
#if JS_HAS_TOSOURCE
|
||||
|
Loading…
Reference in New Issue
Block a user