sys.inspect(Date) now shows the date value
This commit is contained in:
parent
9c6263bff8
commit
98e61db216
10
lib/sys.js
10
lib/sys.js
@ -59,6 +59,11 @@ exports.inspect = function (obj, showHidden) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dates without properties can be shortcutted
|
||||||
|
if (value instanceof Date && keys.length === 0) {
|
||||||
|
return value.toUTCString();
|
||||||
|
}
|
||||||
|
|
||||||
var base, type, braces;
|
var base, type, braces;
|
||||||
// Determine the object type
|
// Determine the object type
|
||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
@ -76,6 +81,11 @@ exports.inspect = function (obj, showHidden) {
|
|||||||
base = "";
|
base = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make dates with properties first say the date
|
||||||
|
if (value instanceof Date) {
|
||||||
|
base = ' ' + value.toUTCString();
|
||||||
|
}
|
||||||
|
|
||||||
seen.push(value);
|
seen.push(value);
|
||||||
|
|
||||||
if (keys.length === 0) {
|
if (keys.length === 0) {
|
||||||
|
@ -10,6 +10,8 @@ assert.equal("[Function]", inspect(function() {}));
|
|||||||
assert.equal('undefined', inspect(undefined));
|
assert.equal('undefined', inspect(undefined));
|
||||||
assert.equal('null', inspect(null));
|
assert.equal('null', inspect(null));
|
||||||
assert.equal('/foo(bar\\n)?/gi', inspect(/foo(bar\n)?/gi));
|
assert.equal('/foo(bar\\n)?/gi', inspect(/foo(bar\n)?/gi));
|
||||||
|
assert.equal('Sun, 14 Feb 2010 11:48:40 GMT',
|
||||||
|
inspect(new Date("Sun, 14 Feb 2010 11:48:40 GMT")));
|
||||||
|
|
||||||
assert.equal("\"\\n\\u0001\"", inspect("\n\u0001"));
|
assert.equal("\"\\n\\u0001\"", inspect("\n\u0001"));
|
||||||
|
|
||||||
@ -79,3 +81,11 @@ assert.equal(
|
|||||||
"{ /123/gi\n \"aprop\": 42\n}",
|
"{ /123/gi\n \"aprop\": 42\n}",
|
||||||
inspect(value)
|
inspect(value)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Dates with properties
|
||||||
|
value = new Date("Sun, 14 Feb 2010 11:48:40 GMT");
|
||||||
|
value.aprop = 42;
|
||||||
|
assert.equal(
|
||||||
|
"{ Sun, 14 Feb 2010 11:48:40 GMT\n \"aprop\": 42\n}",
|
||||||
|
inspect(value)
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user